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 <alessandro.portale@qt.io>
This commit is contained in:
Christian Stenger
2024-06-27 09:28:32 +02:00
parent b45e9bdf3a
commit 49587951aa

View File

@@ -154,6 +154,18 @@ public:
QHash<QString, PerspectiveState> 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);