Merge branch 'master' into software-chooser

This commit is contained in:
Adriaan de Groot 2019-08-03 23:16:38 +02:00
commit 2f2080727d
7 changed files with 155 additions and 109 deletions

View File

@ -26,17 +26,22 @@
#include "utils/Logger.h" #include "utils/Logger.h"
#include "utils/Yaml.h" #include "utils/Yaml.h"
#include "Branding.h"
#include "GlobalStorage.h" #include "GlobalStorage.h"
#include "Job.h" #include "Job.h"
#include "JobQueue.h" #include "JobQueue.h"
#include "Settings.h" #include "Settings.h"
#include "ViewManager.h" #include "ViewManager.h"
#include "modulesystem/ModuleManager.h"
#include <QApplication> #include <QApplication>
#include <QCommandLineOption> #include <QCommandLineOption>
#include <QCommandLineParser> #include <QCommandLineParser>
#include <QCoreApplication> #include <QCoreApplication>
#include <QFileInfo> #include <QFileInfo>
#include <QLabel>
#include <QMainWindow>
#include <memory> #include <memory>
@ -51,13 +56,15 @@ struct ModuleConfig
QString m_jobConfig; QString m_jobConfig;
QString m_globalConfig; QString m_globalConfig;
QString m_language; QString m_language;
QString m_branding;
bool m_ui;
}; };
static ModuleConfig static ModuleConfig
handle_args( QCoreApplication& a ) handle_args( QCoreApplication& a )
{ {
QCommandLineOption debugLevelOption( QCommandLineOption debugLevelOption(
QStringLiteral( "D" ), "Verbose output for debugging purposes (0-8).", "level" ); QStringLiteral( "D" ), "Verbose output for debugging purposes (0-8), ignored.", "level" );
QCommandLineOption globalOption( QStringList() << QStringLiteral( "g" ) << QStringLiteral( "global " ), QCommandLineOption globalOption( QStringList() << QStringLiteral( "g" ) << QStringLiteral( "global " ),
QStringLiteral( "Global settings document" ), QStringLiteral( "Global settings document" ),
"global.yaml" ); "global.yaml" );
@ -67,6 +74,12 @@ handle_args( QCoreApplication& a )
QCommandLineOption langOption( QStringList() << QStringLiteral( "l" ) << QStringLiteral( "language" ), QCommandLineOption langOption( QStringList() << QStringLiteral( "l" ) << QStringLiteral( "language" ),
QStringLiteral( "Language (global)" ), QStringLiteral( "Language (global)" ),
"languagecode" ); "languagecode" );
QCommandLineOption brandOption( QStringList() << QStringLiteral( "b" ) << QStringLiteral( "branding" ),
QStringLiteral( "Branding directory" ),
"path/to/branding.desc",
"src/branding/default/branding.desc" );
QCommandLineOption uiOption( QStringList() << QStringLiteral( "U" ) << QStringLiteral( "ui" ),
QStringLiteral( "Enable UI" ) );
QCommandLineParser parser; QCommandLineParser parser;
parser.setApplicationDescription( "Calamares module tester" ); parser.setApplicationDescription( "Calamares module tester" );
@ -77,27 +90,13 @@ handle_args( QCoreApplication& a )
parser.addOption( globalOption ); parser.addOption( globalOption );
parser.addOption( jobOption ); parser.addOption( jobOption );
parser.addOption( langOption ); parser.addOption( langOption );
parser.addOption( brandOption );
parser.addOption( uiOption );
parser.addPositionalArgument( "module", "Path or name of module to run." ); parser.addPositionalArgument( "module", "Path or name of module to run." );
parser.addPositionalArgument( "job.yaml", "Path of job settings document to use.", "[job.yaml]" ); parser.addPositionalArgument( "job.yaml", "Path of job settings document to use.", "[job.yaml]" );
parser.process( a ); parser.process( a );
if ( parser.isSet( debugLevelOption ) )
{
bool ok = true;
unsigned int l = parser.value( debugLevelOption ).toUInt( &ok );
unsigned int dlevel = 0;
if ( !ok )
{
dlevel = Logger::LOGVERBOSE;
}
else
{
dlevel = l;
}
Logger::setupLogLevel( dlevel );
}
const QStringList args = parser.positionalArguments(); const QStringList args = parser.positionalArguments();
if ( args.isEmpty() ) if ( args.isEmpty() )
{ {
@ -117,7 +116,12 @@ handle_args( QCoreApplication& a )
jobSettings = args.at( 1 ); jobSettings = args.at( 1 );
} }
return ModuleConfig { args.first(), jobSettings, parser.value( globalOption ), parser.value( langOption ) }; return ModuleConfig { args.first(),
jobSettings,
parser.value( globalOption ),
parser.value( langOption ),
parser.value( brandOption ),
parser.isSet( uiOption ) };
} }
} }
@ -184,13 +188,38 @@ load_module( const ModuleConfig& moduleConfig )
return module; return module;
} }
/** @brief Create the right kind of QApplication
*
* Does primitive parsing of argv[] to find the --ui option and returns
* a UI-enabled application if it does.
*
* @p argc must be a reference (to main's argc) because the QCoreApplication
* constructors take a reference as well, and that would otherwise be a
* reference to a temporary.
*/
QCoreApplication*
createApplication( int& argc, char* argv[] )
{
for ( int i = 1; i < argc; ++i )
{
if ( !qstrcmp( argv[ i ], "--ui" ) || !qstrcmp( argv[ i ], "-U" ) )
{
auto* aw = new QApplication( argc, argv );
aw->setQuitOnLastWindowClosed( true );
return aw;
}
}
return new QCoreApplication( argc, argv );
}
int int
main( int argc, char* argv[] ) main( int argc, char* argv[] )
{ {
QCoreApplication a( argc, argv ); QCoreApplication* aw = createApplication( argc, argv );
QApplication* aw = nullptr;
ModuleConfig module = handle_args( a ); Logger::setupLogLevel( Logger::LOGVERBOSE );
ModuleConfig module = handle_args( *aw );
if ( module.moduleName().isEmpty() ) if ( module.moduleName().isEmpty() )
{ {
return 1; return 1;
@ -198,6 +227,7 @@ main( int argc, char* argv[] )
std::unique_ptr< Calamares::Settings > settings_p( new Calamares::Settings( QString(), true ) ); std::unique_ptr< Calamares::Settings > settings_p( new Calamares::Settings( QString(), true ) );
std::unique_ptr< Calamares::JobQueue > jobqueue_p( new Calamares::JobQueue( nullptr ) ); std::unique_ptr< Calamares::JobQueue > jobqueue_p( new Calamares::JobQueue( nullptr ) );
QMainWindow* mw = nullptr;
auto gs = jobqueue_p->globalStorage(); auto gs = jobqueue_p->globalStorage();
if ( !module.globalConfigFile().isEmpty() ) if ( !module.globalConfigFile().isEmpty() )
@ -223,8 +253,11 @@ main( int argc, char* argv[] )
cDebug() << " .. got" << m->name() << m->typeString() << m->interfaceString(); cDebug() << " .. got" << m->name() << m->typeString() << m->interfaceString();
if ( m->type() == Calamares::Module::Type::View ) if ( m->type() == Calamares::Module::Type::View )
{ {
aw = new QApplication( argc, argv ); mw = module.m_ui ? new QMainWindow() : nullptr;
(void)Calamares::ViewManager::instance( nullptr );
(void)new Calamares::Branding( module.m_branding );
(void)new Calamares::ModuleManager( QStringList(), nullptr );
(void)Calamares::ViewManager::instance( mw );
} }
if ( !m->isLoaded() ) if ( !m->isLoaded() )
@ -238,6 +271,16 @@ main( int argc, char* argv[] )
return 1; return 1;
} }
if ( mw )
{
QWidget* w = Calamares::ViewManager::instance()->currentStep()->widget();
w->setParent( mw );
mw->setCentralWidget( w );
w->show();
mw->show();
return aw->exec();
}
using TR = Logger::DebugRow< const char*, const QString >; using TR = Logger::DebugRow< const char*, const QString >;
cDebug() << "Module metadata" << TR( "name", m->name() ) << TR( "type", m->typeString() ) cDebug() << "Module metadata" << TR( "name", m->name() ) << TR( "type", m->typeString() )

View File

@ -21,11 +21,11 @@
#include "LicensePage.h" #include "LicensePage.h"
#include "ui_LicensePage.h"
#include "LicenseWidget.h" #include "LicenseWidget.h"
#include "ui_LicensePage.h"
#include "JobQueue.h"
#include "GlobalStorage.h" #include "GlobalStorage.h"
#include "JobQueue.h"
#include "ViewManager.h" #include "ViewManager.h"
#include "utils/CalamaresUtilsGui.h" #include "utils/CalamaresUtilsGui.h"
@ -36,10 +36,10 @@
#include <QApplication> #include <QApplication>
#include <QBoxLayout> #include <QBoxLayout>
#include <QComboBox>
#include <QDesktopServices> #include <QDesktopServices>
#include <QFocusEvent> #include <QFocusEvent>
#include <QLabel> #include <QLabel>
#include <QComboBox>
#include <QMessageBox> #include <QMessageBox>
#include <algorithm> #include <algorithm>
@ -47,11 +47,11 @@
const NamedEnumTable< LicenseEntry::Type >& const NamedEnumTable< LicenseEntry::Type >&
LicenseEntry::typeNames() LicenseEntry::typeNames()
{ {
static const NamedEnumTable< LicenseEntry::Type > names{ static const NamedEnumTable< LicenseEntry::Type > names {
{ QStringLiteral( "software" ), LicenseEntry::Type::Software}, { QStringLiteral( "software" ), LicenseEntry::Type::Software },
{ QStringLiteral( "driver" ), LicenseEntry::Type::Driver }, { QStringLiteral( "driver" ), LicenseEntry::Type::Driver },
{ QStringLiteral( "gpudriver" ), LicenseEntry::Type::GpuDriver }, { QStringLiteral( "gpudriver" ), LicenseEntry::Type::GpuDriver },
{ QStringLiteral( "browserplugin" ), LicenseEntry::Type::BrowserPlugin}, { QStringLiteral( "browserplugin" ), LicenseEntry::Type::BrowserPlugin },
{ QStringLiteral( "codec" ), LicenseEntry::Type::Codec }, { QStringLiteral( "codec" ), LicenseEntry::Type::Codec },
{ QStringLiteral( "package" ), LicenseEntry::Type::Package } { QStringLiteral( "package" ), LicenseEntry::Type::Package }
}; };
@ -59,10 +59,12 @@ LicenseEntry::typeNames()
return names; return names;
} }
LicenseEntry::LicenseEntry(const QVariantMap& conf) LicenseEntry::LicenseEntry( const QVariantMap& conf )
{ {
if ( !conf.contains( "id" ) || !conf.contains( "name" ) || !conf.contains( "url" ) ) if ( !conf.contains( "id" ) || !conf.contains( "name" ) || !conf.contains( "url" ) )
{
return; return;
}
m_id = conf[ "id" ].toString(); m_id = conf[ "id" ].toString();
m_prettyName = conf[ "name" ].toString(); m_prettyName = conf[ "name" ].toString();
@ -75,7 +77,9 @@ LicenseEntry::LicenseEntry(const QVariantMap& conf)
QString typeString = conf.value( "type", "software" ).toString(); QString typeString = conf.value( "type", "software" ).toString();
m_type = typeNames().find( typeString, ok ); m_type = typeNames().find( typeString, ok );
if ( !ok ) if ( !ok )
{
cWarning() << "License entry" << m_id << "has unknown type" << typeString << "(using 'software')"; cWarning() << "License entry" << m_id << "has unknown type" << typeString << "(using 'software')";
}
} }
bool bool
@ -85,7 +89,7 @@ LicenseEntry::isLocal() const
} }
LicensePage::LicensePage(QWidget *parent) LicensePage::LicensePage( QWidget* parent )
: QWidget( parent ) : QWidget( parent )
, m_isNextEnabled( false ) , m_isNextEnabled( false )
, m_allLicensesOptional( false ) , m_allLicensesOptional( false )
@ -119,9 +123,7 @@ LicensePage::LicensePage(QWidget *parent)
connect( ui->acceptCheckBox, &QCheckBox::toggled, this, &LicensePage::checkAcceptance ); connect( ui->acceptCheckBox, &QCheckBox::toggled, this, &LicensePage::checkAcceptance );
CALAMARES_RETRANSLATE( CALAMARES_RETRANSLATE( ui->acceptCheckBox->setText( tr( "I accept the terms and conditions above." ) ); )
ui->acceptCheckBox->setText( tr( "I accept the terms and conditions above." ) );
)
} }
@ -132,41 +134,40 @@ LicensePage::setEntries( const QList< LicenseEntry >& entriesList )
m_entries.clear(); m_entries.clear();
m_entries.reserve( entriesList.count() ); m_entries.reserve( entriesList.count() );
const bool required = std::any_of( entriesList.cbegin(), entriesList.cend(), []( const LicenseEntry& e ){ return e.m_required; }); const bool required
= std::any_of( entriesList.cbegin(), entriesList.cend(), []( const LicenseEntry& e ) { return e.m_required; } );
if ( entriesList.isEmpty() ) if ( entriesList.isEmpty() )
{
m_allLicensesOptional = true; m_allLicensesOptional = true;
}
else else
{
m_allLicensesOptional = !required; m_allLicensesOptional = !required;
}
checkAcceptance( false ); checkAcceptance( false );
CALAMARES_RETRANSLATE( CALAMARES_RETRANSLATE( if ( required ) {
if ( required ) ui->mainText->setText( tr( "<h1>License Agreement</h1>"
{ "This setup procedure will install proprietary "
ui->mainText->setText( tr( "<h1>License Agreement</h1>" "software that is subject to licensing terms." ) );
"This setup procedure will install proprietary " ui->additionalText->setText( tr( "Please review the End User License "
"software that is subject to licensing terms." ) ); "Agreements (EULAs) above.<br/>"
ui->additionalText->setText( tr( "Please review the End User License " "If you do not agree with the terms, the setup procedure cannot continue." ) );
"Agreements (EULAs) above.<br/>" } else {
"If you do not agree with the terms, the setup procedure cannot continue." ) ); ui->mainText->setText( tr( "<h1>License Agreement</h1>"
} "This setup procedure can install proprietary "
else "software that is subject to licensing terms "
{ "in order to provide additional features and enhance the user "
ui->mainText->setText( tr( "<h1>License Agreement</h1>" "experience." ) );
"This setup procedure can install proprietary " ui->additionalText->setText( tr( "Please review the End User License "
"software that is subject to licensing terms " "Agreements (EULAs) above.<br/>"
"in order to provide additional features and enhance the user " "If you do not agree with the terms, proprietary software will not "
"experience." ) ); "be installed, and open source alternatives will be used instead." ) );
ui->additionalText->setText( tr( "Please review the End User License " } ui->retranslateUi( this );
"Agreements (EULAs) above.<br/>"
"If you do not agree with the terms, proprietary software will not "
"be installed, and open source alternatives will be used instead." ) );
}
ui->retranslateUi( this );
for ( const auto& w : m_entries ) for ( const auto& w
w->retranslateUi(); : m_entries ) w->retranslateUi(); )
)
for ( const LicenseEntry& entry : entriesList ) for ( const LicenseEntry& entry : entriesList )
{ {
@ -190,7 +191,8 @@ LicensePage::updateGlobalStorage( bool v )
Calamares::JobQueue::instance()->globalStorage()->insert( "licenseAgree", v ); Calamares::JobQueue::instance()->globalStorage()->insert( "licenseAgree", v );
} }
void LicensePage::checkAcceptance( bool checked ) void
LicensePage::checkAcceptance( bool checked )
{ {
updateGlobalStorage( checked ); updateGlobalStorage( checked );

View File

@ -24,8 +24,8 @@
#include "utils/NamedEnum.h" #include "utils/NamedEnum.h"
#include <QWidget>
#include <QUrl> #include <QUrl>
#include <QWidget>
namespace Ui namespace Ui
{ {
@ -101,4 +101,4 @@ private:
QList< LicenseWidget* > m_entries; QList< LicenseWidget* > m_entries;
}; };
#endif //LICENSEPAGE_H #endif //LICENSEPAGE_H

View File

@ -19,29 +19,30 @@
#include "LicenseViewStep.h" #include "LicenseViewStep.h"
#include "LicensePage.h"
#include "JobQueue.h"
#include "GlobalStorage.h" #include "GlobalStorage.h"
#include "JobQueue.h"
#include "LicensePage.h"
#include "utils/Logger.h" #include "utils/Logger.h"
#include <QVariantMap> #include <QVariantMap>
CALAMARES_PLUGIN_FACTORY_DEFINITION( LicenseViewStepFactory, registerPlugin<LicenseViewStep>(); ) CALAMARES_PLUGIN_FACTORY_DEFINITION( LicenseViewStepFactory, registerPlugin< LicenseViewStep >(); )
LicenseViewStep::LicenseViewStep( QObject* parent ) LicenseViewStep::LicenseViewStep( QObject* parent )
: Calamares::ViewStep( parent ) : Calamares::ViewStep( parent )
, m_widget( new LicensePage ) , m_widget( new LicensePage )
{ {
emit nextStatusChanged( false ); emit nextStatusChanged( false );
connect( m_widget, &LicensePage::nextStatusChanged, connect( m_widget, &LicensePage::nextStatusChanged, this, &LicenseViewStep::nextStatusChanged );
this, &LicenseViewStep::nextStatusChanged );
} }
LicenseViewStep::~LicenseViewStep() LicenseViewStep::~LicenseViewStep()
{ {
if ( m_widget && m_widget->parent() == nullptr ) if ( m_widget && m_widget->parent() == nullptr )
{
m_widget->deleteLater(); m_widget->deleteLater();
}
} }
@ -97,18 +98,21 @@ void
LicenseViewStep::setConfigurationMap( const QVariantMap& configurationMap ) LicenseViewStep::setConfigurationMap( const QVariantMap& configurationMap )
{ {
QList< LicenseEntry > entriesList; QList< LicenseEntry > entriesList;
if ( configurationMap.contains( "entries" ) && if ( configurationMap.contains( "entries" ) && configurationMap.value( "entries" ).type() == QVariant::List )
configurationMap.value( "entries" ).type() == QVariant::List )
{ {
const auto entries = configurationMap.value( "entries" ).toList(); const auto entries = configurationMap.value( "entries" ).toList();
for ( const QVariant& entryV : entries ) for ( const QVariant& entryV : entries )
{ {
if ( entryV.type() != QVariant::Map ) if ( entryV.type() != QVariant::Map )
{
continue; continue;
}
LicenseEntry entry( entryV.toMap() ); LicenseEntry entry( entryV.toMap() );
if ( entry.isValid() ) if ( entry.isValid() )
{
entriesList.append( entry ); entriesList.append( entry );
}
} }
} }

View File

@ -20,9 +20,9 @@
#ifndef LICENSEPAGEPLUGIN_H #ifndef LICENSEPAGEPLUGIN_H
#define LICENSEPAGEPLUGIN_H #define LICENSEPAGEPLUGIN_H
#include <PluginDllMacro.h>
#include <utils/PluginFactory.h> #include <utils/PluginFactory.h>
#include <viewpages/ViewStep.h> #include <viewpages/ViewStep.h>
#include <PluginDllMacro.h>
#include <QObject> #include <QObject>
#include <QUrl> #include <QUrl>
@ -58,4 +58,4 @@ private:
CALAMARES_PLUGIN_FACTORY_DECLARATION( LicenseViewStepFactory ) CALAMARES_PLUGIN_FACTORY_DECLARATION( LicenseViewStepFactory )
#endif // LICENSEPAGEPLUGIN_H #endif // LICENSEPAGEPLUGIN_H

View File

@ -34,10 +34,12 @@ static QString
loadLocalFile( const QUrl& u ) loadLocalFile( const QUrl& u )
{ {
if ( !u.isLocalFile() ) if ( !u.isLocalFile() )
{
return QString(); return QString();
}
QFile file( u.path() ); QFile file( u.path() );
if ( !file.open(QIODevice::ReadOnly | QIODevice::Text) ) if ( !file.open( QIODevice::ReadOnly | QIODevice::Text ) )
{ {
cWarning() << "Could not load license file" << u.path(); cWarning() << "Could not load license file" << u.path();
return QString(); return QString();
@ -108,11 +110,10 @@ LicenseWidget::LicenseWidget( LicenseEntry entry, QWidget* parent )
retranslateUi(); retranslateUi();
} }
LicenseWidget::~LicenseWidget() LicenseWidget::~LicenseWidget() {}
{
}
void LicenseWidget::retranslateUi() void
LicenseWidget::retranslateUi()
{ {
QString productDescription; QString productDescription;
switch ( m_entry.m_type ) switch ( m_entry.m_type )
@ -120,40 +121,40 @@ void LicenseWidget::retranslateUi()
case LicenseEntry::Type::Driver: case LicenseEntry::Type::Driver:
//: %1 is an untranslatable product name, example: Creative Audigy driver //: %1 is an untranslatable product name, example: Creative Audigy driver
productDescription = tr( "<strong>%1 driver</strong><br/>" productDescription = tr( "<strong>%1 driver</strong><br/>"
"by %2" ) "by %2" )
.arg( m_entry.m_prettyName ) .arg( m_entry.m_prettyName )
.arg( m_entry.m_prettyVendor ); .arg( m_entry.m_prettyVendor );
break; break;
case LicenseEntry::Type::GpuDriver: case LicenseEntry::Type::GpuDriver:
//: %1 is usually a vendor name, example: Nvidia graphics driver //: %1 is usually a vendor name, example: Nvidia graphics driver
productDescription = tr( "<strong>%1 graphics driver</strong><br/>" productDescription = tr( "<strong>%1 graphics driver</strong><br/>"
"<font color=\"Grey\">by %2</font>" ) "<font color=\"Grey\">by %2</font>" )
.arg( m_entry.m_prettyName ) .arg( m_entry.m_prettyName )
.arg( m_entry.m_prettyVendor ); .arg( m_entry.m_prettyVendor );
break; break;
case LicenseEntry::Type::BrowserPlugin: case LicenseEntry::Type::BrowserPlugin:
productDescription = tr( "<strong>%1 browser plugin</strong><br/>" productDescription = tr( "<strong>%1 browser plugin</strong><br/>"
"<font color=\"Grey\">by %2</font>" ) "<font color=\"Grey\">by %2</font>" )
.arg( m_entry.m_prettyName ) .arg( m_entry.m_prettyName )
.arg( m_entry.m_prettyVendor ); .arg( m_entry.m_prettyVendor );
break; break;
case LicenseEntry::Type::Codec: case LicenseEntry::Type::Codec:
productDescription = tr( "<strong>%1 codec</strong><br/>" productDescription = tr( "<strong>%1 codec</strong><br/>"
"<font color=\"Grey\">by %2</font>" ) "<font color=\"Grey\">by %2</font>" )
.arg( m_entry.m_prettyName ) .arg( m_entry.m_prettyName )
.arg( m_entry.m_prettyVendor ); .arg( m_entry.m_prettyVendor );
break; break;
case LicenseEntry::Type::Package: case LicenseEntry::Type::Package:
productDescription = tr( "<strong>%1 package</strong><br/>" productDescription = tr( "<strong>%1 package</strong><br/>"
"<font color=\"Grey\">by %2</font>" ) "<font color=\"Grey\">by %2</font>" )
.arg( m_entry.m_prettyName ) .arg( m_entry.m_prettyName )
.arg( m_entry.m_prettyVendor ); .arg( m_entry.m_prettyVendor );
break; break;
case LicenseEntry::Type::Software: case LicenseEntry::Type::Software:
productDescription = tr( "<strong>%1</strong><br/>" productDescription = tr( "<strong>%1</strong><br/>"
"<font color=\"Grey\">by %2</font>" ) "<font color=\"Grey\">by %2</font>" )
.arg( m_entry.m_prettyName ) .arg( m_entry.m_prettyName )
.arg( m_entry.m_prettyVendor ); .arg( m_entry.m_prettyVendor );
} }
m_label->setText( productDescription ); m_label->setText( productDescription );
updateExpandToolTip(); updateExpandToolTip();
@ -173,7 +174,9 @@ LicenseWidget::expandClicked()
// Show/hide based on the new arrow direction. // Show/hide based on the new arrow direction.
if ( m_fullText ) if ( m_fullText )
{
m_fullText->setHidden( m_expandLicenseButton->arrowType() == Qt::UpArrow ); m_fullText->setHidden( m_expandLicenseButton->arrowType() == Qt::UpArrow );
}
updateExpandToolTip(); updateExpandToolTip();
} }
@ -186,21 +189,15 @@ LicenseWidget::updateExpandToolTip()
{ {
const bool isNowCollapsed = m_expandLicenseButton->arrowType() == Qt::UpArrow; const bool isNowCollapsed = m_expandLicenseButton->arrowType() == Qt::UpArrow;
m_expandLicenseButton->setToolTip( m_expandLicenseButton->setToolTip( isNowCollapsed ? tr( "Shows the complete license text" )
isNowCollapsed : tr( "Hide license text" ) );
? tr( "Shows the complete license text" ) m_viewLicenseLabel->setText( isNowCollapsed ? tr( "Show license agreement" ) : tr( "Hide license agreement" ) );
: tr( "Hide license text" )
) ;
m_viewLicenseLabel->setText(
isNowCollapsed
? tr( "Show license agreement" )
: tr( "Hide license agreement" ) );
} }
else else
{ {
m_expandLicenseButton->setToolTip( tr( "Opens the license agreement in a browser window." ) ); m_expandLicenseButton->setToolTip( tr( "Opens the license agreement in a browser window." ) );
m_viewLicenseLabel->setText( tr( "<a href=\"%1\">View license agreement</a>" ) m_viewLicenseLabel->setText(
.arg( m_entry.m_url.toString() ) ); tr( "<a href=\"%1\">View license agreement</a>" ).arg( m_entry.m_url.toString() ) );
} }
} }

View File

@ -39,7 +39,7 @@ public:
private: private:
void expandClicked(); // "slot" to toggle show/hide of local license text void expandClicked(); // "slot" to toggle show/hide of local license text
void viewClicked(); // "slot" to open link void viewClicked(); // "slot" to open link
void updateExpandToolTip(); void updateExpandToolTip();
LicenseEntry m_entry; LicenseEntry m_entry;
@ -47,5 +47,5 @@ private:
QLabel* m_viewLicenseLabel; QLabel* m_viewLicenseLabel;
QToolButton* m_expandLicenseButton; QToolButton* m_expandLicenseButton;
QLabel* m_fullText; QLabel* m_fullText;
} ; };
#endif #endif