From 86c2a44c212779db52b579baea13aaad3b4a76f1 Mon Sep 17 00:00:00 2001
From: Christian Stenger <christian.stenger@theqtcompany.com>
Date: Wed, 9 Mar 2016 13:54:27 +0100
Subject: [PATCH] Debugger: Use fixed size for perspective combo box...

...to avoid adjusting the width again and again while debugging.

Change-Id: I67f68b2d54d9f3f9a32cbf1049b4f9e9bd63e010
Reviewed-by: hjk <hjk@theqtcompany.com>
---
 src/plugins/debugger/debuggermainwindow.cpp | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/plugins/debugger/debuggermainwindow.cpp b/src/plugins/debugger/debuggermainwindow.cpp
index b0970d70c8b..60f629961a9 100644
--- a/src/plugins/debugger/debuggermainwindow.cpp
+++ b/src/plugins/debugger/debuggermainwindow.cpp
@@ -96,6 +96,16 @@ void DebuggerMainWindow::registerPerspective(const QByteArray &perspectiveId, co
 {
     m_perspectiveForPerspectiveId.insert(perspectiveId, perspective);
     m_perspectiveChooser->addItem(perspective.name(), perspectiveId);
+    // adjust width if necessary
+    const int oldWidth = m_perspectiveChooser->width();
+    const int contentWidth = m_perspectiveChooser->fontMetrics().width(perspective.name());
+    QStyleOptionComboBox option;
+    option.initFrom(m_perspectiveChooser);
+    const QSize sz(contentWidth, 1);
+    const int width = m_perspectiveChooser->style()->sizeFromContents(
+                QStyle::CT_ComboBox, &option, sz).width();
+    if (width > oldWidth)
+        m_perspectiveChooser->setFixedWidth(width);
 }
 
 void DebuggerMainWindow::registerToolbar(const QByteArray &perspectiveId, QWidget *widget)
-- 
GitLab