From 605d567cc4d312befb0cda18559547b072a2b105 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 7 Apr 2012 18:11:24 +0200 Subject: [PATCH] Set minimum height of workbench switcher to show all items when possible --- src/Gui/Action.cpp | 13 +++++++++++++ src/Gui/Action.h | 1 + 2 files changed, 14 insertions(+) diff --git a/src/Gui/Action.cpp b/src/Gui/Action.cpp index 7086c82c7..5e39c8a51 100644 --- a/src/Gui/Action.cpp +++ b/src/Gui/Action.cpp @@ -28,6 +28,7 @@ # include # include # include +# include # include # include # include @@ -345,6 +346,18 @@ WorkbenchComboBox::~WorkbenchComboBox() { } +void WorkbenchComboBox::showPopup() +{ + int rows = count(); + if (rows > 0) { + int height = view()->sizeHintForRow(0); + int maxHeight = QApplication::desktop()->height(); + view()->setMinimumHeight(qMin(height * rows, maxHeight/2)); + } + + QComboBox::showPopup(); +} + void WorkbenchComboBox::actionEvent ( QActionEvent* e ) { QAction *action = e->action(); diff --git a/src/Gui/Action.h b/src/Gui/Action.h index 4a0dc7a6e..0b33f57ec 100644 --- a/src/Gui/Action.h +++ b/src/Gui/Action.h @@ -124,6 +124,7 @@ class GuiExport WorkbenchComboBox : public QComboBox public: WorkbenchComboBox(WorkbenchGroup* wb, QWidget* parent=0); virtual ~WorkbenchComboBox(); + void showPopup(); public Q_SLOTS: void onActivated(int);