forked from qt-creator/qt-creator
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:
@@ -250,6 +250,7 @@ public:
|
|||||||
QPointer<GenericProposalInfoFrame> m_infoFrame;
|
QPointer<GenericProposalInfoFrame> m_infoFrame;
|
||||||
QTimer m_infoTimer;
|
QTimer m_infoTimer;
|
||||||
CodeAssistant *m_assistant;
|
CodeAssistant *m_assistant;
|
||||||
|
bool m_autoWidth;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void handleActivation(const QModelIndex &modelIndex);
|
void handleActivation(const QModelIndex &modelIndex);
|
||||||
@@ -264,6 +265,7 @@ GenericProposalWidgetPrivate::GenericProposalWidgetPrivate(QWidget *completionWi
|
|||||||
, m_explicitlySelected(false)
|
, m_explicitlySelected(false)
|
||||||
, m_justInvoked(false)
|
, m_justInvoked(false)
|
||||||
, m_assistant(0)
|
, m_assistant(0)
|
||||||
|
, m_autoWidth(true)
|
||||||
{
|
{
|
||||||
connect(m_completionListView, SIGNAL(activated(QModelIndex)),
|
connect(m_completionListView, SIGNAL(activated(QModelIndex)),
|
||||||
this, SLOT(handleActivation(QModelIndex)));
|
this, SLOT(handleActivation(QModelIndex)));
|
||||||
@@ -328,6 +330,10 @@ GenericProposalWidget::GenericProposalWidget()
|
|||||||
d->m_completionListView->setMinimumSize(1, 1);
|
d->m_completionListView->setMinimumSize(1, 1);
|
||||||
connect(d->m_completionListView->verticalScrollBar(), SIGNAL(valueChanged(int)),
|
connect(d->m_completionListView->verticalScrollBar(), SIGNAL(valueChanged(int)),
|
||||||
this, SLOT(updatePositionAndSize()));
|
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);
|
QVBoxLayout *layout = new QVBoxLayout(this);
|
||||||
layout->setMargin(0);
|
layout->setMargin(0);
|
||||||
@@ -492,6 +498,9 @@ bool GenericProposalWidget::updateAndCheck(const QString &prefix)
|
|||||||
|
|
||||||
void GenericProposalWidget::updatePositionAndSize()
|
void GenericProposalWidget::updatePositionAndSize()
|
||||||
{
|
{
|
||||||
|
if (!d->m_autoWidth)
|
||||||
|
return;
|
||||||
|
|
||||||
const QSize &shint = d->m_completionListView->calculateSize();
|
const QSize &shint = d->m_completionListView->calculateSize();
|
||||||
const int fw = frameWidth();
|
const int fw = frameWidth();
|
||||||
const int width = shint.width() + fw * 2 + 30;
|
const int width = shint.width() + fw * 2 + 30;
|
||||||
@@ -514,6 +523,17 @@ void GenericProposalWidget::updatePositionAndSize()
|
|||||||
setGeometry(pos.x(), pos.y(), width, height);
|
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)
|
bool GenericProposalWidget::eventFilter(QObject *o, QEvent *e)
|
||||||
{
|
{
|
||||||
if (e->type() == QEvent::FocusOut) {
|
if (e->type() == QEvent::FocusOut) {
|
||||||
|
@@ -65,6 +65,8 @@ private:
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updatePositionAndSize();
|
void updatePositionAndSize();
|
||||||
|
void turnOffAutoWidth();
|
||||||
|
void turnOnAutoWidth();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool eventFilter(QObject *o, QEvent *e);
|
virtual bool eventFilter(QObject *o, QEvent *e);
|
||||||
|
Reference in New Issue
Block a user