From ddf541774b729f7919693355d78a16bf19bfec37 Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Tue, 23 Apr 2019 04:10:43 -0400 Subject: [PATCH] [license] Make local and external links more consistent - Capitalization of message - Add a right-pointing "open" button to external links as well --- src/modules/license/LicenseWidget.cpp | 19 +++++++++++++++++-- src/modules/license/LicenseWidget.h | 3 ++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/modules/license/LicenseWidget.cpp b/src/modules/license/LicenseWidget.cpp index 7a52f4e9e..bf20ffc51 100644 --- a/src/modules/license/LicenseWidget.cpp +++ b/src/modules/license/LicenseWidget.cpp @@ -21,6 +21,7 @@ #include "LicenseWidget.h" +#include #include #include #include @@ -61,8 +62,16 @@ LicenseWidget::LicenseWidget( LicenseEntry entry, QWidget* parent ) connect( m_expandLicenseButton, &QAbstractButton::clicked, this, &LicenseWidget::expandClicked ); } else - m_viewLicenseLabel->setOpenExternalLinks( true ); + { + auto* button = new QToolButton( this ); + button->setArrowType( Qt::RightArrow ); + wiLayout->addWidget( button ); + connect( button, &QAbstractButton::clicked, this, &LicenseWidget::viewClicked ); + // Normally setOpenExternalLinks( true ) would do, but we need the + // open code anyway for the toolbutton, let's share it. + connect( m_viewLicenseLabel, &QLabel::linkActivated, this, &LicenseWidget::viewClicked ); + } retranslateUi(); } @@ -122,7 +131,7 @@ void LicenseWidget::retranslateUi() updateExpandToolTip(); } else - m_viewLicenseLabel->setText( tr( "view license agreement" ) + m_viewLicenseLabel->setText( tr( "View license agreement" ) .arg( m_entry.m_url.toString() ) ); } @@ -152,3 +161,9 @@ LicenseWidget::updateExpandToolTip() : tr( "Hide license text" ) ) ; } + +void +LicenseWidget::viewClicked() +{ + QDesktopServices::openUrl( m_entry.m_url ); +} diff --git a/src/modules/license/LicenseWidget.h b/src/modules/license/LicenseWidget.h index ab6a91491..dcddf7f3c 100644 --- a/src/modules/license/LicenseWidget.h +++ b/src/modules/license/LicenseWidget.h @@ -38,7 +38,8 @@ public: void retranslateUi(); private: - void expandClicked(); + void expandClicked(); // "slot" to toggle show/hide of local license text + void viewClicked(); // "slot" to open link void updateExpandToolTip(); LicenseEntry m_entry;