From 49587951aafd3c63da2fdb81403dbaf13ffa5f1e Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Thu, 27 Jun 2024 09:28:32 +0200 Subject: [PATCH] Debugger: Tweak perspective switcher combo box On Windows it is hard to figure out which of the items you want to choose. The popup's menu on Windows just gets the width of the current item and therefore you may only see mid-elided items holding a leading and a trailing letter. This patch makes the popup behave like it does on Linux or macOS where the width is always wide enough to display the items correctly. Change-Id: I53d155fc64b765692c071886cca883f376c86a82 Reviewed-by: Alessandro Portale --- src/plugins/debugger/debuggermainwindow.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/plugins/debugger/debuggermainwindow.cpp b/src/plugins/debugger/debuggermainwindow.cpp index 4ad44368168..c1f4b14028d 100644 --- a/src/plugins/debugger/debuggermainwindow.cpp +++ b/src/plugins/debugger/debuggermainwindow.cpp @@ -154,6 +154,18 @@ public: QHash m_lastTypePerspectiveStates; // Perspective::settingsId() -> MainWindow::state() }; +class TweakedCombo : public QComboBox // ensures that all items of the popup are readable +{ +public: + explicit TweakedCombo(QWidget *parent = nullptr) : QComboBox(parent) {} + void showPopup() override + { + QTC_ASSERT(view(), return); + view()->setMinimumWidth(view()->sizeHintForColumn(0)); + QComboBox::showPopup(); + } +}; + DebuggerMainWindowPrivate::DebuggerMainWindowPrivate(DebuggerMainWindow *parent) : q(parent) { @@ -164,7 +176,7 @@ DebuggerMainWindowPrivate::DebuggerMainWindowPrivate(DebuggerMainWindow *parent) m_statusLabel->setIndent(2 * QFontMetrics(q->font()).horizontalAdvance(QChar('x'))); m_editorPlaceHolder = new EditorManagerPlaceHolder; - m_perspectiveChooser = new QComboBox; + m_perspectiveChooser = new TweakedCombo; m_perspectiveChooser->setObjectName("PerspectiveChooser"); StyleHelper::setPanelWidget(m_perspectiveChooser); m_perspectiveChooser->setSizeAdjustPolicy(QComboBox::AdjustToContents);