forked from qt-creator/qt-creator
Put some space between completion info tooltip and delay appearing
Done with mae and Jens Bache-Wiig.
This commit is contained in:
@@ -45,7 +45,6 @@
|
|||||||
#include <QtGui/QLabel>
|
#include <QtGui/QLabel>
|
||||||
#include <QtGui/QStylePainter>
|
#include <QtGui/QStylePainter>
|
||||||
#include <QtGui/QToolTip>
|
#include <QtGui/QToolTip>
|
||||||
#include <QtCore/QTimer>
|
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
@@ -256,6 +255,10 @@ CompletionListView::CompletionListView(CompletionSupport *support, ITextEditable
|
|||||||
{
|
{
|
||||||
QTC_ASSERT(m_editorWidget, return);
|
QTC_ASSERT(m_editorWidget, return);
|
||||||
|
|
||||||
|
m_infoTimer.setInterval(1000);
|
||||||
|
m_infoTimer.setSingleShot(true);
|
||||||
|
connect(&m_infoTimer, SIGNAL(timeout()), SLOT(maybeShowInfoTip()));
|
||||||
|
|
||||||
setAttribute(Qt::WA_MacShowFocusRect, false);
|
setAttribute(Qt::WA_MacShowFocusRect, false);
|
||||||
setUniformItemSizes(true);
|
setUniformItemSizes(true);
|
||||||
setSelectionBehavior(QAbstractItemView::SelectItems);
|
setSelectionBehavior(QAbstractItemView::SelectItems);
|
||||||
@@ -269,7 +272,6 @@ CompletionListView::CompletionListView(CompletionSupport *support, ITextEditable
|
|||||||
if (verticalScrollBar())
|
if (verticalScrollBar())
|
||||||
verticalScrollBar()->setAttribute(Qt::WA_MacMiniSize);
|
verticalScrollBar()->setAttribute(Qt::WA_MacMiniSize);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CompletionListView::~CompletionListView()
|
CompletionListView::~CompletionListView()
|
||||||
@@ -285,6 +287,7 @@ void CompletionListView::maybeShowInfoTip()
|
|||||||
|
|
||||||
if (infoTip.isEmpty()) {
|
if (infoTip.isEmpty()) {
|
||||||
delete m_infoFrame.data();
|
delete m_infoFrame.data();
|
||||||
|
m_infoTimer.setInterval(200);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -295,19 +298,21 @@ void CompletionListView::maybeShowInfoTip()
|
|||||||
QRect r = rectForIndex(current);
|
QRect r = rectForIndex(current);
|
||||||
m_infoFrame->move(
|
m_infoFrame->move(
|
||||||
(parentWidget()->mapToGlobal(
|
(parentWidget()->mapToGlobal(
|
||||||
parentWidget()->rect().topRight() + QPoint(0, 0))).x(),
|
parentWidget()->rect().topRight())).x() + 3,
|
||||||
mapToGlobal(r.topRight()).y() - verticalOffset()
|
mapToGlobal(r.topRight()).y() - verticalOffset()
|
||||||
);
|
);
|
||||||
m_infoFrame->setText(infoTip);
|
m_infoFrame->setText(infoTip);
|
||||||
m_infoFrame->adjustSize();
|
m_infoFrame->adjustSize();
|
||||||
m_infoFrame->show();
|
m_infoFrame->show();
|
||||||
m_infoFrame->raise();
|
m_infoFrame->raise();
|
||||||
|
|
||||||
|
m_infoTimer.setInterval(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CompletionListView::currentChanged(const QModelIndex ¤t, const QModelIndex &previous)
|
void CompletionListView::currentChanged(const QModelIndex ¤t, const QModelIndex &previous)
|
||||||
{
|
{
|
||||||
QListView::currentChanged(current, previous);
|
QListView::currentChanged(current, previous);
|
||||||
QTimer::singleShot(0, this, SLOT(maybeShowInfoTip()));
|
m_infoTimer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -31,7 +31,8 @@
|
|||||||
#define COMPLETIONWIDGET_H
|
#define COMPLETIONWIDGET_H
|
||||||
|
|
||||||
#include <QtGui/QListView>
|
#include <QtGui/QListView>
|
||||||
#include <QPointer>
|
#include <QtCore/QPointer>
|
||||||
|
#include <QtCore/QTimer>
|
||||||
|
|
||||||
namespace TextEditor {
|
namespace TextEditor {
|
||||||
|
|
||||||
@@ -113,6 +114,7 @@ private:
|
|||||||
AutoCompletionModel *m_model;
|
AutoCompletionModel *m_model;
|
||||||
CompletionSupport *m_support;
|
CompletionSupport *m_support;
|
||||||
QPointer<CompletionInfoFrame> m_infoFrame;
|
QPointer<CompletionInfoFrame> m_infoFrame;
|
||||||
|
QTimer m_infoTimer;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
Reference in New Issue
Block a user