QskMenu implementation simplified
This commit is contained in:
parent
33b3ddb5e3
commit
e64e1b6cbb
@ -42,6 +42,8 @@ class QSK_EXPORT QskLabelData
|
||||
void setIcon( const QskIcon& );
|
||||
QskIcon icon() const noexcept;
|
||||
|
||||
bool isEmpty() const;
|
||||
|
||||
QskHashValue hash( QskHashValue ) const;
|
||||
|
||||
private:
|
||||
@ -71,6 +73,11 @@ inline bool QskLabelData::operator!=( const QskLabelData& other ) const noexcept
|
||||
return ( !( *this == other ) );
|
||||
}
|
||||
|
||||
inline bool QskLabelData::isEmpty() const
|
||||
{
|
||||
return m_text.isEmpty() && m_icon.isNull();
|
||||
}
|
||||
|
||||
QSK_EXPORT QVector< QskLabelData > qskCreateLabelData( const QStringList& );
|
||||
|
||||
#ifndef QT_NO_DEBUG_STREAM
|
||||
|
@ -120,18 +120,16 @@ class QskMenuSkinlet::PrivateData
|
||||
const auto h = qMax( hint.height(), textHeight );
|
||||
|
||||
qreal maxW = 0.0;
|
||||
for ( int i = 0; i < menu->count(); i++ )
|
||||
|
||||
const auto options = menu->options();
|
||||
for ( auto& option : options )
|
||||
{
|
||||
const auto sample = skinlet->sampleAt( menu, QskMenu::Icon, i );
|
||||
if ( sample.canConvert< QskGraphic >() )
|
||||
const auto graphic = option.icon().graphic();
|
||||
if ( !graphic.isNull() )
|
||||
{
|
||||
const auto graphic = sample.value< QskGraphic >();
|
||||
if ( !graphic.isNull() )
|
||||
{
|
||||
const auto w = graphic.widthForHeight( h );
|
||||
if( w > maxW )
|
||||
maxW = w;
|
||||
}
|
||||
const auto w = graphic.widthForHeight( h );
|
||||
if( w > maxW )
|
||||
maxW = w;
|
||||
}
|
||||
}
|
||||
|
||||
@ -146,18 +144,14 @@ class QskMenuSkinlet::PrivateData
|
||||
|
||||
auto maxWidth = 0.0;
|
||||
|
||||
for ( int i = 0; i < menu->count(); i++ )
|
||||
const auto options = menu->options();
|
||||
for ( auto& option : options )
|
||||
{
|
||||
const auto sample = skinlet->sampleAt( menu, QskMenu::Text, i );
|
||||
if ( sample.canConvert< QString >() )
|
||||
if( !option.text().isEmpty() )
|
||||
{
|
||||
const auto text = sample.toString();
|
||||
if( !text.isEmpty() )
|
||||
{
|
||||
const auto w = qskHorizontalAdvance( fm, text );
|
||||
if( w > maxWidth )
|
||||
maxWidth = w;
|
||||
}
|
||||
const auto w = qskHorizontalAdvance( fm, option.text() );
|
||||
if( w > maxWidth )
|
||||
maxWidth = w;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user