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