[license] Use more meaningful names for arrows

- The arrows Up, Down, Right are used on toolbuttons, but
   in the context of this module, those are directions with
   meaning; give them better names.
 - Because of #1268, the meaning of up- and down- may be swapped;
   I'm not sure of which look makes the most sense. This is prep-
   work for easily swapping the looks by using the meaningful names
   instead.

SEE #1268
This commit is contained in:
Adriaan de Groot 2019-11-28 13:23:11 +01:00
parent d322d783ea
commit c870fca787

View File

@ -30,6 +30,10 @@
#include <QToolButton> #include <QToolButton>
#include <QVBoxLayout> #include <QVBoxLayout>
static constexpr const auto ArrowOpenExternalLink = Qt::RightArrow;
static constexpr const auto ArrowLocalLicenseIsCollapsed = Qt::UpArrow;
static constexpr const auto ArrowLocalLicenseIsExpanded = Qt::DownArrow;
static QString static QString
loadLocalFile( const QUrl& u ) loadLocalFile( const QUrl& u )
{ {
@ -82,7 +86,7 @@ LicenseWidget::LicenseWidget( LicenseEntry entry, QWidget* parent )
{ {
QVBoxLayout* vLayout = new QVBoxLayout; QVBoxLayout* vLayout = new QVBoxLayout;
m_expandLicenseButton->setArrowType( Qt::UpArrow ); m_expandLicenseButton->setArrowType( ArrowLocalLicenseIsCollapsed );
connect( m_expandLicenseButton, &QAbstractButton::clicked, this, &LicenseWidget::expandClicked ); connect( m_expandLicenseButton, &QAbstractButton::clicked, this, &LicenseWidget::expandClicked );
vLayout->addLayout( wiLayout ); vLayout->addLayout( wiLayout );
@ -97,7 +101,7 @@ LicenseWidget::LicenseWidget( LicenseEntry entry, QWidget* parent )
} }
else else
{ {
m_expandLicenseButton->setArrowType( Qt::RightArrow ); m_expandLicenseButton->setArrowType( ArrowOpenExternalLink );
connect( m_expandLicenseButton, &QAbstractButton::clicked, this, &LicenseWidget::viewClicked ); connect( m_expandLicenseButton, &QAbstractButton::clicked, this, &LicenseWidget::viewClicked );
// Normally setOpenExternalLinks( true ) would do, but we need the // Normally setOpenExternalLinks( true ) would do, but we need the
@ -163,19 +167,19 @@ LicenseWidget::retranslateUi()
void void
LicenseWidget::expandClicked() LicenseWidget::expandClicked()
{ {
if ( m_expandLicenseButton->arrowType() == Qt::DownArrow ) if ( m_expandLicenseButton->arrowType() == ArrowLocalLicenseIsExpanded )
{ {
m_expandLicenseButton->setArrowType( Qt::UpArrow ); m_expandLicenseButton->setArrowType( ArrowLocalLicenseIsCollapsed );
} }
else else
{ {
m_expandLicenseButton->setArrowType( Qt::DownArrow ); m_expandLicenseButton->setArrowType( ArrowLocalLicenseIsExpanded );
} }
// 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() == ArrowLocalLicenseIsCollapsed );
} }
updateExpandToolTip(); updateExpandToolTip();
@ -187,7 +191,7 @@ LicenseWidget::updateExpandToolTip()
{ {
if ( m_entry.isLocal() ) if ( m_entry.isLocal() )
{ {
const bool isNowCollapsed = m_expandLicenseButton->arrowType() == Qt::UpArrow; const bool isNowCollapsed = m_expandLicenseButton->arrowType() == ArrowLocalLicenseIsCollapsed;
m_expandLicenseButton->setToolTip( isNowCollapsed ? tr( "Shows the complete license text" ) m_expandLicenseButton->setToolTip( isNowCollapsed ? tr( "Shows the complete license text" )
: tr( "Hide license text" ) ); : tr( "Hide license text" ) );