From da3b83589b970f6a40365193f1f339d58d8a0d3f Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Tue, 11 Aug 2020 20:35:58 +0200 Subject: [PATCH] Core: Consider scroll bar when positioning the VariableChooser Change-Id: Ia9fcade4f32bc852d5519c984b6e84ab443e044e Reviewed-by: Eike Ziller --- src/plugins/coreplugin/variablechooser.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/plugins/coreplugin/variablechooser.cpp b/src/plugins/coreplugin/variablechooser.cpp index 47566407d8b..eae123fbb0f 100644 --- a/src/plugins/coreplugin/variablechooser.cpp +++ b/src/plugins/coreplugin/variablechooser.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -466,9 +467,15 @@ void VariableChooserPrivate::updateButtonGeometry() { QWidget *current = currentWidget(); int margin = buttonMargin(); + int rightPadding = 0; + if (const auto scrollArea = qobject_cast(current)) { + rightPadding = m_textEdit->verticalScrollBar()->isVisible() ? + m_textEdit->verticalScrollBar()->width() : 0; + } m_iconButton->setGeometry(current->rect().adjusted( current->width() - (margin + 4), 0, - 0, -qMax(0, current->height() - (margin + 4)))); + 0, -qMax(0, current->height() - (margin + 4))) + .translated(-rightPadding, 0)); } void VariableChooserPrivate::updateCurrentEditor(QWidget *old, QWidget *widget) @@ -629,7 +636,7 @@ bool VariableChooser::eventFilter(QObject *obj, QEvent *event) if ((event->type() == QEvent::KeyPress || event->type() == QEvent::ShortcutOverride) && isVisible()) { auto ke = static_cast(event); return handleEscapePressed(ke, this); - } else if (event->type() == QEvent::Resize) { + } else if (event->type() == QEvent::Resize || event->type() == QEvent::LayoutRequest) { d->updateButtonGeometry(); } else if (event->type() == QEvent::Hide) { close();