Commit 33fedfea authored by Friedemann Kleint's avatar Friedemann Kleint

Qt4ProjectManager: Give a verbose tooltip on the Qt versions.

Reviewed-by: default avatardt <qtc-committer@nokia.com>
parent 7c12dad4
......@@ -17,6 +17,8 @@
#include <QtCore/QDebug>
#include <QtCore/QDir>
#include <QtCore/QDateTime>
#include <QtGui/QHelpEvent>
#include <QtGui/QToolTip>
using namespace Qt4ProjectManager;
using namespace Qt4ProjectManager::Internal;
......@@ -133,6 +135,7 @@ QtOptionsPageWidget::QtOptionsPageWidget(QWidget *parent, QList<QtVersion *> ver
// setup parent items for auto-detected and manual versions
m_ui->qtdirList->header()->setResizeMode(QHeaderView::ResizeToContents);
QTreeWidgetItem *autoItem = new QTreeWidgetItem(m_ui->qtdirList);
m_ui->qtdirList->installEventFilter(this);
autoItem->setText(0, tr("Auto-detected"));
autoItem->setFirstColumnSpanned(true);
QTreeWidgetItem *manualItem = new QTreeWidgetItem(m_ui->qtdirList);
......@@ -200,6 +203,26 @@ QtOptionsPageWidget::QtOptionsPageWidget(QWidget *parent, QList<QtVersion *> ver
updateState();
}
bool QtOptionsPageWidget::eventFilter(QObject *o, QEvent *e)
{
// Set the items tooltip, which may cause costly initialization
// of QtVersion and must be up-to-date
if (o != m_ui->qtdirList || e->type() != QEvent::ToolTip)
return false;
QHelpEvent *helpEvent = static_cast<QHelpEvent *>(e);
const QPoint treePos = helpEvent->pos() - QPoint(0, m_ui->qtdirList->header()->height());
QTreeWidgetItem *item = m_ui->qtdirList->itemAt(treePos);
if (!item)
return false;
const int index = indexForTreeItem(item);
if (index == -1)
return false;
const QString tooltip = m_versions.at(index)->toHtml();
QToolTip::showText(helpEvent->globalPos(), tooltip, m_ui->qtdirList);
helpEvent->accept();
return true;
}
int QtOptionsPageWidget::currentIndex() const
{
if (QTreeWidgetItem *currentItem = m_ui->qtdirList->currentItem())
......
......@@ -82,6 +82,8 @@ public:
int defaultVersion() const;
void finish();
virtual bool eventFilter(QObject *o, QEvent *e);
private:
void showEnvironmentPage(QTreeWidgetItem * item);
void fixQtVersionName(int index);
......
......@@ -51,6 +51,7 @@
#include <QtCore/QSettings>
#include <QtCore/QTime>
#include <QtCore/QTimer>
#include <QtCore/QTextStream>
#include <QtGui/QApplication>
#include <QtGui/QDesktopServices>
......@@ -482,6 +483,46 @@ QtVersion::~QtVersion()
}
QString QtVersion::toHtml() const
{
QString rc;
QTextStream str(&rc);
str << "<html></head><body><table>";
str << "<tr><td><b>" << QtVersionManager::tr("Name:")
<< "</b></td><td>" << name() << "</td></tr>";
str << "<tr><td><b>" << QtVersionManager::tr("Source:")
<< "</b></td><td>" << sourcePath() << "</td></tr>";
str << "<tr><td><b>" << QtVersionManager::tr("mkspec:")
<< "</b></td><td>" << mkspec() << "</td></tr>";
str << "<tr><td><b>" << QtVersionManager::tr("qmake:")
<< "</b></td><td>" << m_qmakeCommand << "</td></tr>";
updateVersionInfo();
if (m_defaultConfigIsDebug || m_defaultConfigIsDebugAndRelease) {
str << "<tr><td><b>" << QtVersionManager::tr("Default:") << "</b></td><td>";
if (m_defaultConfigIsDebug)
str << "debug";
if (m_defaultConfigIsDebugAndRelease)
str << "default_and_release";
str << "</td></tr>";
} // default config.
if (!qmakeCXX().isEmpty())
str << "<tr><td><b>" << QtVersionManager::tr("Compiler:")
<< "</b></td><td>" << qmakeCXX() << "</td></tr>";
str << "<tr><td><b>" << QtVersionManager::tr("Version:")
<< "</b></td><td>" << qtVersionString() << "</td></tr>";
if (hasDebuggingHelper())
str << "<tr><td><b>" << QtVersionManager::tr("Debugging helper:")
<< "</b></td><td>" << debuggingHelperLibrary() << "</td></tr>";
const QHash<QString,QString> vInfo = versionInfo();
if (!vInfo.isEmpty()) {
const QHash<QString,QString>::const_iterator vcend = vInfo.constEnd();
for (QHash<QString,QString>::const_iterator it = vInfo.constBegin(); it != vcend; ++it)
str << "<tr><td><pre>" << it.key() << "</pre></td><td>" << it.value() << "</td></tr>";
}
str << "<table></body></html>";
return rc;
}
QString QtVersion::name() const
{
return m_name;
......@@ -1307,7 +1348,7 @@ bool QtVersion::isQt64Bit() const
#ifdef Q_OS_WIN32
# ifdef __GNUC__ // MinGW lacking some definitions/winbase.h
# define SCS_64BIT_BINARY 6
# endif
# endif
DWORD binaryType = 0;
bool success = GetBinaryTypeW(reinterpret_cast<const TCHAR*>(make.utf16()), &binaryType) != 0;
if (success && binaryType == SCS_64BIT_BINARY)
......
......@@ -124,6 +124,9 @@ public:
};
QmakeBuildConfig defaultBuildConfig() const;
QString toHtml() const;
private:
static int getUniqueId();
// Also used by QtOptionsPageWidget
......
Markdown is supported
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