Commit 37a95617 authored by David Schulz's avatar David Schulz
Browse files

Editor: Fix resizing of proposal widged



Stop resizing width on scrolling the proposal
widget via drag of the scrollbar.

Task-number: QTCREATORBUG-7925
Change-Id: I948a0ec1bba8a9294b8a65b5eaa72063bbede48f
Reviewed-by: default avatarChristian Stenger <christian.stenger@digia.com>
parent dff07614
......@@ -250,6 +250,7 @@ public:
QPointer<GenericProposalInfoFrame> m_infoFrame;
QTimer m_infoTimer;
CodeAssistant *m_assistant;
bool m_autoWidth;
public slots:
void handleActivation(const QModelIndex &modelIndex);
......@@ -264,6 +265,7 @@ GenericProposalWidgetPrivate::GenericProposalWidgetPrivate(QWidget *completionWi
, m_explicitlySelected(false)
, m_justInvoked(false)
, m_assistant(0)
, m_autoWidth(true)
{
connect(m_completionListView, SIGNAL(activated(QModelIndex)),
this, SLOT(handleActivation(QModelIndex)));
......@@ -328,6 +330,10 @@ GenericProposalWidget::GenericProposalWidget()
d->m_completionListView->setMinimumSize(1, 1);
connect(d->m_completionListView->verticalScrollBar(), SIGNAL(valueChanged(int)),
this, SLOT(updatePositionAndSize()));
connect(d->m_completionListView->verticalScrollBar(), SIGNAL(sliderPressed()),
this, SLOT(turnOffAutoWidth()));
connect(d->m_completionListView->verticalScrollBar(), SIGNAL(sliderReleased()),
this, SLOT(turnOnAutoWidth()));
QVBoxLayout *layout = new QVBoxLayout(this);
layout->setMargin(0);
......@@ -492,6 +498,9 @@ bool GenericProposalWidget::updateAndCheck(const QString &prefix)
void GenericProposalWidget::updatePositionAndSize()
{
if (!d->m_autoWidth)
return;
const QSize &shint = d->m_completionListView->calculateSize();
const int fw = frameWidth();
const int width = shint.width() + fw * 2 + 30;
......@@ -514,6 +523,17 @@ void GenericProposalWidget::updatePositionAndSize()
setGeometry(pos.x(), pos.y(), width, height);
}
void GenericProposalWidget::turnOffAutoWidth()
{
d->m_autoWidth = false;
}
void GenericProposalWidget::turnOnAutoWidth()
{
d->m_autoWidth = true;
updatePositionAndSize();
}
bool GenericProposalWidget::eventFilter(QObject *o, QEvent *e)
{
if (e->type() == QEvent::FocusOut) {
......
......@@ -65,6 +65,8 @@ private:
private slots:
void updatePositionAndSize();
void turnOffAutoWidth();
void turnOnAutoWidth();
protected:
virtual bool eventFilter(QObject *o, QEvent *e);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment