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: Christian Stenger <christian.stenger@digia.com>
This commit is contained in:
David Schulz
2012-09-26 09:46:44 +02:00
parent dff0761406
commit 37a95617f2
2 changed files with 22 additions and 0 deletions

View File

@@ -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) {

View File

@@ -65,6 +65,8 @@ private:
private slots:
void updatePositionAndSize();
void turnOffAutoWidth();
void turnOnAutoWidth();
protected:
virtual bool eventFilter(QObject *o, QEvent *e);