QskSegmentedBar fixed for Squiek, loading the checkmark as symbolHint
This commit is contained in:
parent
f45946726f
commit
e3b62e0896
|
@ -561,8 +561,8 @@ void Editor::setupSegmentedBar()
|
||||||
setStrutSize( Q::Segment | A::Horizontal, segmentStrutSize );
|
setStrutSize( Q::Segment | A::Horizontal, segmentStrutSize );
|
||||||
setStrutSize( Q::Segment | A::Vertical, segmentStrutSize.transposed() );
|
setStrutSize( Q::Segment | A::Vertical, segmentStrutSize.transposed() );
|
||||||
setGradient( Q::Segment, Qt::transparent );
|
setGradient( Q::Segment, Qt::transparent );
|
||||||
setPadding( Q::Segment | A::Horizontal, { 12_dp, 0, 12_dp, 0 } );
|
setPadding( Q::Segment | A::Horizontal, 12_dp, 0, 12_dp, 0 );
|
||||||
setPadding( Q::Segment | A::Vertical, { 0, 12_dp, 0, 12_dp } );
|
setPadding( Q::Segment | A::Vertical, 0, 12_dp, 0, 12_dp );
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -597,6 +597,9 @@ void Editor::setupSegmentedBar()
|
||||||
|
|
||||||
setGradient( Q::Cursor, m_pal.secondaryContainer );
|
setGradient( Q::Cursor, m_pal.secondaryContainer );
|
||||||
setGradient( Q::Cursor | Q::Disabled, m_pal.onSurface12 );
|
setGradient( Q::Cursor | Q::Disabled, m_pal.onSurface12 );
|
||||||
|
|
||||||
|
setBoxBorderMetrics( Q::Cursor, 1_dp );
|
||||||
|
setBoxBorderColors( Q::Cursor, Qt::transparent );
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -615,6 +618,8 @@ void Editor::setupSegmentedBar()
|
||||||
{
|
{
|
||||||
// Graphic
|
// Graphic
|
||||||
|
|
||||||
|
setSymbol( Q::Graphic, symbol( QskStandardSymbol::SegmentedBarCheckMark ) );
|
||||||
|
|
||||||
setPadding( Q::Graphic, 0_dp );
|
setPadding( Q::Graphic, 0_dp );
|
||||||
setStrutSize( Q::Graphic, 18_dp, 18_dp );
|
setStrutSize( Q::Graphic, 18_dp, 18_dp );
|
||||||
|
|
||||||
|
|
|
@ -42,17 +42,20 @@ namespace
|
||||||
|
|
||||||
QskGraphic graphicAt( const QskSegmentedBar* bar, const int index )
|
QskGraphic graphicAt( const QskSegmentedBar* bar, const int index )
|
||||||
{
|
{
|
||||||
// note: It is a Material 3 peculiarity that the selected element
|
using Q = QskSegmentedBar;
|
||||||
// always has the checkmark symbol. If we ever have another style
|
|
||||||
// implementing this control we should put this code into a
|
|
||||||
// subclass.
|
|
||||||
const auto graphic = ( bar->selectedIndex() == index )
|
|
||||||
? bar->effectiveSkin()->symbol( QskStandardSymbol::SegmentedBarCheckMark )
|
|
||||||
: qskValueAt< QskGraphic >( bar, index );
|
|
||||||
|
|
||||||
|
if ( bar->selectedIndex() == index )
|
||||||
|
{
|
||||||
|
// f.e Material 3 replaces the icon of the selected element by a checkmark
|
||||||
|
|
||||||
|
const auto graphic = bar->symbolHint( Q::Graphic | Q::Selected );
|
||||||
|
if ( !graphic.isNull() )
|
||||||
return graphic;
|
return graphic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return qskValueAt< QskGraphic >( bar, index );
|
||||||
|
}
|
||||||
|
|
||||||
class LayoutEngine : public QskSubcontrolLayoutEngine
|
class LayoutEngine : public QskSubcontrolLayoutEngine
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -79,8 +82,8 @@ namespace
|
||||||
QskSegmentedBarSkinlet::QskSegmentedBarSkinlet( QskSkin* skin )
|
QskSegmentedBarSkinlet::QskSegmentedBarSkinlet( QskSkin* skin )
|
||||||
: Inherited( skin )
|
: Inherited( skin )
|
||||||
{
|
{
|
||||||
setNodeRoles( { CursorRole, PanelRole, SegmentRole,
|
setNodeRoles( { PanelRole, SegmentRole,
|
||||||
SeparatorRole, TextRole, GraphicRole } );
|
SeparatorRole, CursorRole, TextRole, GraphicRole } );
|
||||||
}
|
}
|
||||||
|
|
||||||
QskSegmentedBarSkinlet::~QskSegmentedBarSkinlet() = default;
|
QskSegmentedBarSkinlet::~QskSegmentedBarSkinlet() = default;
|
||||||
|
@ -227,15 +230,16 @@ QSizeF QskSegmentedBarSkinlet::segmentSizeHint(
|
||||||
|
|
||||||
QSizeF sizeMax;
|
QSizeF sizeMax;
|
||||||
|
|
||||||
|
const auto graphic0 = bar->symbolHint( Q::Graphic | Q::Selected );
|
||||||
|
|
||||||
for ( int i = 0; i < bar->count(); i++ )
|
for ( int i = 0; i < bar->count(); i++ )
|
||||||
{
|
{
|
||||||
LayoutEngine layoutEngine( bar, i );
|
LayoutEngine layoutEngine( bar, i );
|
||||||
|
|
||||||
const auto graphic = bar->effectiveSkin()->symbol(
|
auto graphic = qskValueAt< QskGraphic >( bar, i );
|
||||||
QskStandardSymbol::SegmentedBarCheckMark );
|
if ( graphic.isNull() )
|
||||||
|
graphic = graphic0;
|
||||||
|
|
||||||
// We want to know how big the element can grow when it is selected,
|
|
||||||
// i.e. when it has the checkmark symbol:
|
|
||||||
layoutEngine.setGraphicTextElements( bar,
|
layoutEngine.setGraphicTextElements( bar,
|
||||||
Q::Text, qskValueAt< QString >( bar, i ),
|
Q::Text, qskValueAt< QString >( bar, i ),
|
||||||
Q::Graphic, graphic.defaultSize() );
|
Q::Graphic, graphic.defaultSize() );
|
||||||
|
@ -243,10 +247,8 @@ QSizeF QskSegmentedBarSkinlet::segmentSizeHint(
|
||||||
const auto size = layoutEngine.sizeHint( which, QSizeF() );
|
const auto size = layoutEngine.sizeHint( which, QSizeF() );
|
||||||
|
|
||||||
if( size.width() > sizeMax.width() )
|
if( size.width() > sizeMax.width() )
|
||||||
{
|
|
||||||
sizeMax = size;
|
sizeMax = size;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
sizeMax = bar->outerBoxSize( Q::Segment, sizeMax );
|
sizeMax = bar->outerBoxSize( Q::Segment, sizeMax );
|
||||||
sizeMax = sizeMax.expandedTo( bar->strutSizeHint( Q::Segment ) );
|
sizeMax = sizeMax.expandedTo( bar->strutSizeHint( Q::Segment ) );
|
||||||
|
|
Loading…
Reference in New Issue