From 2cebfd001f8b2cde3c3477d4aebe8ce2e10ff29e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thorbj=C3=B8rn=20Lindeijer?= <thorbjorn.lindeijer@nokia.com> Date: Thu, 15 Apr 2010 14:34:31 +0200 Subject: [PATCH] Put some space between completion info tooltip and delay appearing Done with mae and Jens Bache-Wiig. --- src/plugins/texteditor/completionwidget.cpp | 13 +++++++++---- src/plugins/texteditor/completionwidget.h | 4 +++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/plugins/texteditor/completionwidget.cpp b/src/plugins/texteditor/completionwidget.cpp index 8c0b4f19e61..3fc70927ae8 100644 --- a/src/plugins/texteditor/completionwidget.cpp +++ b/src/plugins/texteditor/completionwidget.cpp @@ -45,7 +45,6 @@ #include <QtGui/QLabel> #include <QtGui/QStylePainter> #include <QtGui/QToolTip> -#include <QtCore/QTimer> #include <limits.h> @@ -256,6 +255,10 @@ CompletionListView::CompletionListView(CompletionSupport *support, ITextEditable { 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); setUniformItemSizes(true); setSelectionBehavior(QAbstractItemView::SelectItems); @@ -269,7 +272,6 @@ CompletionListView::CompletionListView(CompletionSupport *support, ITextEditable if (verticalScrollBar()) verticalScrollBar()->setAttribute(Qt::WA_MacMiniSize); #endif - } CompletionListView::~CompletionListView() @@ -285,6 +287,7 @@ void CompletionListView::maybeShowInfoTip() if (infoTip.isEmpty()) { delete m_infoFrame.data(); + m_infoTimer.setInterval(200); return; } @@ -295,19 +298,21 @@ void CompletionListView::maybeShowInfoTip() QRect r = rectForIndex(current); m_infoFrame->move( (parentWidget()->mapToGlobal( - parentWidget()->rect().topRight() + QPoint(0, 0))).x(), + parentWidget()->rect().topRight())).x() + 3, mapToGlobal(r.topRight()).y() - verticalOffset() ); m_infoFrame->setText(infoTip); m_infoFrame->adjustSize(); m_infoFrame->show(); m_infoFrame->raise(); + + m_infoTimer.setInterval(0); } void CompletionListView::currentChanged(const QModelIndex ¤t, const QModelIndex &previous) { QListView::currentChanged(current, previous); - QTimer::singleShot(0, this, SLOT(maybeShowInfoTip())); + m_infoTimer.start(); } diff --git a/src/plugins/texteditor/completionwidget.h b/src/plugins/texteditor/completionwidget.h index c16e0155076..ece02904b11 100644 --- a/src/plugins/texteditor/completionwidget.h +++ b/src/plugins/texteditor/completionwidget.h @@ -31,7 +31,8 @@ #define COMPLETIONWIDGET_H #include <QtGui/QListView> -#include <QPointer> +#include <QtCore/QPointer> +#include <QtCore/QTimer> namespace TextEditor { @@ -113,6 +114,7 @@ private: AutoCompletionModel *m_model; CompletionSupport *m_support; QPointer<CompletionInfoFrame> m_infoFrame; + QTimer m_infoTimer; }; } // namespace Internal -- GitLab