[license] Massage display of buttons
- try to keep them the same height - show the URL that will be opened
This commit is contained in:
parent
6e1504fafc
commit
7330afd96a
@ -53,7 +53,7 @@ LicenseWidget::LicenseWidget( LicenseEntry entry, QWidget* parent )
|
||||
, m_entry( std::move( entry ) )
|
||||
, m_label( new QLabel( this ) )
|
||||
, m_viewLicenseButton( new QPushButton( this ) )
|
||||
, m_fullText( nullptr )
|
||||
, m_licenceTextLabel( new QLabel( this ) )
|
||||
, m_isExpanded( m_entry.expandByDefault() )
|
||||
{
|
||||
QPalette pal( palette() );
|
||||
@ -69,33 +69,40 @@ LicenseWidget::LicenseWidget( LicenseEntry entry, QWidget* parent )
|
||||
QHBoxLayout* wiLayout = new QHBoxLayout;
|
||||
|
||||
m_label->setWordWrap( true );
|
||||
m_label->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Minimum );
|
||||
m_label->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
|
||||
wiLayout->addWidget( m_label );
|
||||
|
||||
m_viewLicenseButton->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Minimum );
|
||||
wiLayout->addSpacing( 1 );
|
||||
m_viewLicenseButton->setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
|
||||
wiLayout->addWidget( m_viewLicenseButton );
|
||||
|
||||
QVBoxLayout* vLayout = new QVBoxLayout;
|
||||
vLayout->addLayout( wiLayout );
|
||||
m_licenceTextLabel->setStyleSheet( "border-top: 1px solid black; margin-top: 0px; padding-top: 1em;" );
|
||||
m_licenceTextLabel->setObjectName( "licenseItemFullText" );
|
||||
|
||||
if ( m_entry.isLocal() )
|
||||
{
|
||||
QVBoxLayout* vLayout = new QVBoxLayout;
|
||||
vLayout->addLayout( wiLayout );
|
||||
m_fullText = new QLabel( this );
|
||||
m_fullText->setText( loadLocalFile( m_entry.m_url ) );
|
||||
m_fullText->setStyleSheet( "border-top: 1px solid black; margin-top: 1em; padding-top: 1em;" );
|
||||
m_fullText->setObjectName( "licenseItemFullText" );
|
||||
|
||||
m_fullText->setHidden( !m_isExpanded );
|
||||
|
||||
vLayout->addWidget( m_fullText );
|
||||
setLayout( vLayout );
|
||||
m_fullTextContents = loadLocalFile( m_entry.m_url );
|
||||
if ( m_isExpanded )
|
||||
{
|
||||
m_licenceTextLabel->setText( m_fullTextContents );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_licenceTextLabel->setText( tr( "URL: %1" ).arg( m_entry.m_url.toDisplayString() ) );
|
||||
}
|
||||
connect( m_viewLicenseButton, &QAbstractButton::clicked, this, &LicenseWidget::expandClicked );
|
||||
}
|
||||
else
|
||||
{
|
||||
setLayout( wiLayout ); // Only the horizontal layout needed
|
||||
m_licenceTextLabel->setText( tr( "URL: %1" ).arg( m_entry.m_url.toDisplayString() ) );
|
||||
connect( m_viewLicenseButton, &QAbstractButton::clicked, this, &LicenseWidget::viewClicked );
|
||||
}
|
||||
|
||||
vLayout->addWidget( m_licenceTextLabel );
|
||||
setLayout( vLayout );
|
||||
|
||||
retranslateUi();
|
||||
}
|
||||
|
||||
@ -154,9 +161,16 @@ LicenseWidget::expandClicked()
|
||||
{
|
||||
m_isExpanded = !m_isExpanded;
|
||||
// Show/hide based on the new arrow direction.
|
||||
if ( m_fullText )
|
||||
if ( !m_fullTextContents.isEmpty() )
|
||||
{
|
||||
m_fullText->setHidden( !m_isExpanded );
|
||||
if ( m_isExpanded )
|
||||
{
|
||||
m_licenceTextLabel->setText( m_fullTextContents );
|
||||
}
|
||||
else
|
||||
{
|
||||
m_licenceTextLabel->setText( tr( "URL: %1" ).arg( m_entry.m_url.toDisplayString() ) );
|
||||
}
|
||||
}
|
||||
|
||||
updateExpandToolTip();
|
||||
|
@ -45,7 +45,8 @@ private:
|
||||
LicenseEntry m_entry;
|
||||
QLabel* m_label;
|
||||
QPushButton* m_viewLicenseButton;
|
||||
QLabel* m_fullText;
|
||||
QLabel* m_licenceTextLabel;
|
||||
QString m_fullTextContents;
|
||||
bool m_isExpanded;
|
||||
};
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user