forked from qt-creator/qt-creator
Qt version options page: Replace (large) tooltip by details widget.
Remove the tooltip that has grown overly large for Qt 5 by a row containing a details text browser. Filter out the '/raw', '/get' variables, display all paths with the correct separator as a clickable link that opens a file browser. Change-Id: I81fee8e5be04c87b5b59b8fc444f75efa66fcaa0 Reviewed-by: Orgad Shaneh <orgads@gmail.com> Reviewed-by: Tobias Hunger <tobias.hunger@nokia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
This commit is contained in:
@@ -51,6 +51,7 @@
|
|||||||
#include <utils/synchronousprocess.h>
|
#include <utils/synchronousprocess.h>
|
||||||
|
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
#include <QUrl>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
@@ -474,8 +475,24 @@ QString BaseQtVersion::toHtml(bool verbose) const
|
|||||||
const QHash<QString,QString> vInfo = versionInfo();
|
const QHash<QString,QString> vInfo = versionInfo();
|
||||||
if (!vInfo.isEmpty()) {
|
if (!vInfo.isEmpty()) {
|
||||||
const QHash<QString,QString>::const_iterator vcend = vInfo.constEnd();
|
const QHash<QString,QString>::const_iterator vcend = vInfo.constEnd();
|
||||||
for (QHash<QString,QString>::const_iterator it = vInfo.constBegin(); it != vcend; ++it)
|
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>";
|
const QString &variableName = it.key();
|
||||||
|
const QString &value = it.value();
|
||||||
|
if (!variableName.endsWith(QLatin1String("/raw")) && !variableName.endsWith(QLatin1String("/get"))) {
|
||||||
|
const bool isPath = !value.isEmpty() &&
|
||||||
|
(variableName == QLatin1String("QMAKE_MKSPECS")
|
||||||
|
|| variableName.contains(QLatin1String("HOST"))
|
||||||
|
|| variableName.contains(QLatin1String("INSTALL")));
|
||||||
|
str << "<tr><td><pre>" << variableName << "</pre></td><td>";
|
||||||
|
if (isPath) {
|
||||||
|
str << "<a href=\"" << QUrl::fromLocalFile(value).toString()
|
||||||
|
<< "\">" << QDir::toNativeSeparators(value) << "</a>";
|
||||||
|
} else {
|
||||||
|
str << it.value() ;
|
||||||
|
}
|
||||||
|
str << "</td></tr>";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -58,6 +58,8 @@
|
|||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
#include <QTextBrowser>
|
||||||
|
#include <QDesktopServices>
|
||||||
|
|
||||||
enum ModelRoles { VersionIdRole = Qt::UserRole, ToolChainIdRole, BuildLogRole, BuildRunningRole};
|
enum ModelRoles { VersionIdRole = Qt::UserRole, ToolChainIdRole, BuildLogRole, BuildRunningRole};
|
||||||
|
|
||||||
@@ -110,6 +112,7 @@ QtOptionsPageWidget::QtOptionsPageWidget(QWidget *parent)
|
|||||||
, m_ui(new Internal::Ui::QtVersionManager())
|
, m_ui(new Internal::Ui::QtVersionManager())
|
||||||
, m_versionUi(new Internal::Ui::QtVersionInfo())
|
, m_versionUi(new Internal::Ui::QtVersionInfo())
|
||||||
, m_debuggingHelperUi(new Internal::Ui::DebuggingHelper())
|
, m_debuggingHelperUi(new Internal::Ui::DebuggingHelper())
|
||||||
|
, m_infoBrowser(new QTextBrowser)
|
||||||
, m_invalidVersionIcon(QLatin1String(":/projectexplorer/images/compile_error.png"))
|
, m_invalidVersionIcon(QLatin1String(":/projectexplorer/images/compile_error.png"))
|
||||||
, m_warningVersionIcon(QLatin1String(":/projectexplorer/images/compile_warning.png"))
|
, m_warningVersionIcon(QLatin1String(":/projectexplorer/images/compile_warning.png"))
|
||||||
, m_configurationWidget(0)
|
, m_configurationWidget(0)
|
||||||
@@ -125,6 +128,11 @@ QtOptionsPageWidget::QtOptionsPageWidget(QWidget *parent)
|
|||||||
|
|
||||||
m_ui->setupUi(this);
|
m_ui->setupUi(this);
|
||||||
|
|
||||||
|
m_infoBrowser->setOpenLinks(false);
|
||||||
|
m_infoBrowser->setTextInteractionFlags(Qt::TextBrowserInteraction);
|
||||||
|
connect(m_infoBrowser, SIGNAL(anchorClicked(QUrl)), this, SLOT(infoAnchorClicked(QUrl)));
|
||||||
|
m_ui->infoWidget->setWidget(m_infoBrowser);
|
||||||
|
|
||||||
m_ui->versionInfoWidget->setWidget(versionInfoWidget);
|
m_ui->versionInfoWidget->setWidget(versionInfoWidget);
|
||||||
m_ui->versionInfoWidget->setState(Utils::DetailsWidget::NoSummary);
|
m_ui->versionInfoWidget->setState(Utils::DetailsWidget::NoSummary);
|
||||||
|
|
||||||
@@ -137,7 +145,6 @@ QtOptionsPageWidget::QtOptionsPageWidget(QWidget *parent)
|
|||||||
m_ui->qtdirList->header()->setStretchLastSection(false);
|
m_ui->qtdirList->header()->setStretchLastSection(false);
|
||||||
m_ui->qtdirList->setTextElideMode(Qt::ElideNone);
|
m_ui->qtdirList->setTextElideMode(Qt::ElideNone);
|
||||||
m_autoItem = new QTreeWidgetItem(m_ui->qtdirList);
|
m_autoItem = new QTreeWidgetItem(m_ui->qtdirList);
|
||||||
m_ui->qtdirList->installEventFilter(this);
|
|
||||||
m_autoItem->setText(0, tr("Auto-detected"));
|
m_autoItem->setText(0, tr("Auto-detected"));
|
||||||
m_autoItem->setFirstColumnSpanned(true);
|
m_autoItem->setFirstColumnSpanned(true);
|
||||||
m_autoItem->setFlags(Qt::ItemIsEnabled);
|
m_autoItem->setFlags(Qt::ItemIsEnabled);
|
||||||
@@ -199,26 +206,6 @@ QtOptionsPageWidget::QtOptionsPageWidget(QWidget *parent)
|
|||||||
this, SLOT(toolChainsUpdated()));
|
this, SLOT(toolChainsUpdated()));
|
||||||
}
|
}
|
||||||
|
|
||||||
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(true);
|
|
||||||
QToolTip::showText(helpEvent->globalPos(), tooltip, m_ui->qtdirList);
|
|
||||||
helpEvent->accept();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
int QtOptionsPageWidget::currentIndex() const
|
int QtOptionsPageWidget::currentIndex() const
|
||||||
{
|
{
|
||||||
if (QTreeWidgetItem *currentItem = m_ui->qtdirList->currentItem())
|
if (QTreeWidgetItem *currentItem = m_ui->qtdirList->currentItem())
|
||||||
@@ -354,6 +341,11 @@ void QtOptionsPageWidget::handleDebuggingHelperExpanded(bool expanded)
|
|||||||
m_ui->versionInfoWidget->setVisible(!expanded);
|
m_ui->versionInfoWidget->setVisible(!expanded);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QtOptionsPageWidget::infoAnchorClicked(const QUrl &url)
|
||||||
|
{
|
||||||
|
QDesktopServices::openUrl(url);
|
||||||
|
}
|
||||||
|
|
||||||
QtOptionsPageWidget::ValidityInfo QtOptionsPageWidget::validInformation(const BaseQtVersion *version)
|
QtOptionsPageWidget::ValidityInfo QtOptionsPageWidget::validInformation(const BaseQtVersion *version)
|
||||||
{
|
{
|
||||||
ValidityInfo info;
|
ValidityInfo info;
|
||||||
@@ -362,6 +354,7 @@ QtOptionsPageWidget::ValidityInfo QtOptionsPageWidget::validInformation(const Ba
|
|||||||
if (!version)
|
if (!version)
|
||||||
return info;
|
return info;
|
||||||
|
|
||||||
|
info.description = tr("Qt version %1 for %2").arg(version->qtVersionString(), version->description());
|
||||||
if (!version->isValid()) {
|
if (!version->isValid()) {
|
||||||
info.icon = m_invalidVersionIcon;
|
info.icon = m_invalidVersionIcon;
|
||||||
info.message = version->invalidReason();
|
info.message = version->invalidReason();
|
||||||
@@ -381,20 +374,19 @@ QtOptionsPageWidget::ValidityInfo QtOptionsPageWidget::validInformation(const Ba
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool useable = true;
|
bool useable = true;
|
||||||
if (missingToolChains.isEmpty()) {
|
if (!missingToolChains.isEmpty()) {
|
||||||
// No:
|
if (missingToolChains.count() == abiCount) {
|
||||||
info.message = tr("Qt version %1 for %2").arg(version->qtVersionString(), version->description());
|
// Yes, this Qt version can't be used at all!
|
||||||
} else if (missingToolChains.count() == abiCount) {
|
info.message = tr("No tool chain can produce code for this Qt version. Please define one or more tool chains.");
|
||||||
// Yes, this Qt version can't be used at all!
|
info.icon = m_invalidVersionIcon;
|
||||||
info.message = tr("No tool chain can produce code for this Qt version. Please define one or more tool chains.");
|
useable = false;
|
||||||
info.icon = m_invalidVersionIcon;
|
} else {
|
||||||
useable = false;
|
// Yes, some ABIs are unsupported
|
||||||
} else {
|
info.message = tr("Not all possible target environments can be supported due to missing tool chains.");
|
||||||
// Yes, some ABIs are unsupported
|
info.toolTip = tr("The following ABIs are currently not supported:<ul><li>%1</li></ul>")
|
||||||
info.message = tr("Not all possible target environments can be supported due to missing tool chains.");
|
.arg(missingToolChains.join(QLatin1String("</li><li>")));
|
||||||
info.toolTip = tr("The following ABIs are currently not supported:<ul><li>%1</li></ul>")
|
info.icon = m_warningVersionIcon;
|
||||||
.arg(missingToolChains.join(QLatin1String("</li><li>")));
|
}
|
||||||
info.icon = m_warningVersionIcon;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (useable) {
|
if (useable) {
|
||||||
@@ -943,11 +935,26 @@ void QtOptionsPageWidget::qtVersionChanged()
|
|||||||
void QtOptionsPageWidget::updateDescriptionLabel()
|
void QtOptionsPageWidget::updateDescriptionLabel()
|
||||||
{
|
{
|
||||||
QTreeWidgetItem *item = m_ui->qtdirList->currentItem();
|
QTreeWidgetItem *item = m_ui->qtdirList->currentItem();
|
||||||
const ValidityInfo info = validInformation(currentVersion());
|
const BaseQtVersion *version = currentVersion();
|
||||||
m_versionUi->errorLabel->setText(info.message);
|
const ValidityInfo info = validInformation(version);
|
||||||
m_versionUi->errorLabel->setToolTip(info.toolTip);
|
if (info.message.isEmpty()) {
|
||||||
|
m_versionUi->errorLabel->setVisible(false);
|
||||||
|
} else {
|
||||||
|
m_versionUi->errorLabel->setVisible(true);
|
||||||
|
m_versionUi->errorLabel->setText(info.message);
|
||||||
|
m_versionUi->errorLabel->setToolTip(info.toolTip);
|
||||||
|
}
|
||||||
|
m_ui->infoWidget->setSummaryText(info.description);
|
||||||
if (item)
|
if (item)
|
||||||
item->setIcon(0, info.icon);
|
item->setIcon(0, info.icon);
|
||||||
|
|
||||||
|
if (version) {
|
||||||
|
m_infoBrowser->setHtml(version->toHtml(true));
|
||||||
|
m_ui->infoWidget->setVisible(true);
|
||||||
|
} else {
|
||||||
|
m_infoBrowser->setHtml(QString());
|
||||||
|
m_ui->infoWidget->setVisible(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int QtOptionsPageWidget::indexForTreeItem(const QTreeWidgetItem *item) const
|
int QtOptionsPageWidget::indexForTreeItem(const QTreeWidgetItem *item) const
|
||||||
|
@@ -41,6 +41,8 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QTreeWidgetItem;
|
class QTreeWidgetItem;
|
||||||
|
class QTextBrowser;
|
||||||
|
class QUrl;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
@@ -71,8 +73,6 @@ public:
|
|||||||
void apply();
|
void apply();
|
||||||
QString searchKeywords() const;
|
QString searchKeywords() const;
|
||||||
|
|
||||||
virtual bool eventFilter(QObject *o, QEvent *e);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateDescriptionLabel();
|
void updateDescriptionLabel();
|
||||||
void userChangedCurrentVersion();
|
void userChangedCurrentVersion();
|
||||||
@@ -90,6 +90,7 @@ private:
|
|||||||
Internal::Ui::QtVersionManager *m_ui;
|
Internal::Ui::QtVersionManager *m_ui;
|
||||||
Internal::Ui::QtVersionInfo *m_versionUi;
|
Internal::Ui::QtVersionInfo *m_versionUi;
|
||||||
Internal::Ui::DebuggingHelper *m_debuggingHelperUi;
|
Internal::Ui::DebuggingHelper *m_debuggingHelperUi;
|
||||||
|
QTextBrowser *m_infoBrowser;
|
||||||
QList<BaseQtVersion *> m_versions;
|
QList<BaseQtVersion *> m_versions;
|
||||||
int m_defaultVersion;
|
int m_defaultVersion;
|
||||||
QIcon m_invalidVersionIcon;
|
QIcon m_invalidVersionIcon;
|
||||||
@@ -121,9 +122,11 @@ private slots:
|
|||||||
|
|
||||||
void qtVersionsDumpUpdated(const Utils::FileName &qmakeCommand);
|
void qtVersionsDumpUpdated(const Utils::FileName &qmakeCommand);
|
||||||
void handleDebuggingHelperExpanded(bool expanded);
|
void handleDebuggingHelperExpanded(bool expanded);
|
||||||
|
void infoAnchorClicked(const QUrl &);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct ValidityInfo {
|
struct ValidityInfo {
|
||||||
|
QString description;
|
||||||
QString message;
|
QString message;
|
||||||
QString toolTip;
|
QString toolTip;
|
||||||
QIcon icon;
|
QIcon icon;
|
||||||
|
@@ -95,6 +95,9 @@
|
|||||||
<widget class="Utils::DetailsWidget" name="versionInfoWidget" native="true"/>
|
<widget class="Utils::DetailsWidget" name="versionInfoWidget" native="true"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
|
<widget class="Utils::DetailsWidget" name="infoWidget" native="true"/>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0">
|
||||||
<widget class="Utils::DetailsWidget" name="debuggingHelperWidget" native="true"/>
|
<widget class="Utils::DetailsWidget" name="debuggingHelperWidget" native="true"/>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
Reference in New Issue
Block a user