diff options
author | Arttu Tarkiainen <arttu.tarkiainen@qt.io> | 2019-05-03 13:54:38 +0300 |
---|---|---|
committer | Arttu Tarkiainen <arttu.tarkiainen@qt.io> | 2019-05-07 08:38:04 +0000 |
commit | 04a3e327847cb0382f0276ed16841cd3711088b8 (patch) | |
tree | 84499e5fc59f6e84fc3291d4a3e4278f2cc4d4be | |
parent | aba1d564ce9f087eaf164c4d0489efa15fd30ce7 (diff) |
Enable links and text selection in component description fields
External links can now be included in component description by specifying
a proper URL address like this: {external-link}='https://www.qt.io/'.
The link fields can be placed anywhere inside package <Description> tags.
Task-number: QTIFW-1292
Change-Id: I1d916a58224bdfb6e885445873bf541fad3cf834
Reviewed-by: Tarja Sundqvist <tarja.sundqvist@qt.io>
Reviewed-by: Katja Marttila <katja.marttila@qt.io>
-rw-r--r-- | doc/installerfw.qdoc | 5 | ||||
-rw-r--r-- | src/libs/installer/componentselectionpage_p.cpp | 13 |
2 files changed, 15 insertions, 3 deletions
diff --git a/doc/installerfw.qdoc b/doc/installerfw.qdoc index 0589c8c14..09c7e575a 100644 --- a/doc/installerfw.qdoc +++ b/doc/installerfw.qdoc @@ -585,7 +585,10 @@ Translations may be specified similarly to DisplayName tag. If a localization that matches the locale is not found and an untranslated version exists, that one will be used. Otherwise no Description will be - shown for that locale. + shown for that locale. User clickable external links, for example a component's + homepage, can be included in component description by specifying a URL + address like this: {external-link}='https://www.qt.io/'. The URL must be valid + and contain a full path to the desired resource. \row \li Version \li Version number of the component in the following format: diff --git a/src/libs/installer/componentselectionpage_p.cpp b/src/libs/installer/componentselectionpage_p.cpp index 34cd1e634..82c1b79e3 100644 --- a/src/libs/installer/componentselectionpage_p.cpp +++ b/src/libs/installer/componentselectionpage_p.cpp @@ -77,6 +77,8 @@ ComponentSelectionPagePrivate::ComponentSelectionPagePrivate(ComponentSelectionP m_descriptionLabel = new QLabel(q); m_descriptionLabel->setWordWrap(true); + m_descriptionLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); + m_descriptionLabel->setOpenExternalLinks(true); m_descriptionLabel->setObjectName(QLatin1String("ComponentDescriptionLabel")); m_descriptionLabel->setAlignment(Qt::AlignTop); m_descriptionScrollArea->setWidget(m_descriptionLabel); @@ -296,8 +298,15 @@ void ComponentSelectionPagePrivate::currentSelectedChanged(const QModelIndex &cu return; m_sizeLabel->setText(QString()); - m_descriptionLabel->setText(m_currentModel->data(m_currentModel->index(current.row(), - ComponentModelHelper::NameColumn, current.parent()), Qt::ToolTipRole).toString()); + + QString description = m_currentModel->data(m_currentModel->index(current.row(), + ComponentModelHelper::NameColumn, current.parent()), Qt::ToolTipRole).toString(); + + // replace {external-link}='' fields in component description with proper link tags + description.replace(QRegularExpression(QLatin1String("{external-link}='(.*?)'")), + QLatin1String("<a href=\"\\1\"><span style=\"color:#17a81a;\">\\1</span></a>")); + + m_descriptionLabel->setText(description); Component *component = m_currentModel->componentFromIndex(current); if ((m_core->isUninstaller()) || (!component)) |