code cleanup

This commit is contained in:
Uwe Rathmann 2019-02-28 08:06:44 +01:00
parent 4e00c73f92
commit f8016125b1
3 changed files with 11 additions and 39 deletions

View File

@ -51,27 +51,6 @@ MyToggleButton::MyToggleButton( QQuickItem* parent )
initSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Fixed );
}
MyToggleButton::MyToggleButton(
const QString& checkedIcon, const QString& uncheckedIcon, QQuickItem* parent )
: MyToggleButton( parent )
{
if ( !uncheckedIcon.isEmpty() )
{
auto& data = m_data->content[ UncheckedSection ];
data.iconSource = uncheckedIcon;
data.iconDirty = true;
}
if ( !checkedIcon.isEmpty() )
{
auto& data = m_data->content[ CheckedSection ];
data.iconSource = checkedIcon;
data.iconDirty = true;
}
}
MyToggleButton::~MyToggleButton()
{
}

View File

@ -19,17 +19,8 @@ class MyToggleButton : public QskAbstractButton
public:
QSK_SUBCONTROLS( Panel, Cursor, CheckedPanel, CheckedLabel, CheckedIcon,
UncheckedPanel, UncheckedLabel, UncheckedIcon )
enum
{
UncheckedSection = 0,
CheckedSection = 1
};
MyToggleButton( QQuickItem* parent = nullptr );
MyToggleButton( const QString& ckeckedIcon, const QString& uncheckedIcon,
QQuickItem* parent = nullptr );
~MyToggleButton() override;
void setTextAt( int index, const QString& );

View File

@ -26,9 +26,11 @@ MyToggleButtonSkinlet::MyToggleButtonSkinlet( QskSkin* skin )
{
// sorted in stacking order
setNodeRoles( { PanelRole, CursorRole, UncheckedPanelRole, UncheckedLabelRole,
UncheckedIconRole, CheckedPanelRole, CheckedLabelRole, CheckedIconRole
} );
setNodeRoles(
{ PanelRole, CursorRole, UncheckedPanelRole, UncheckedLabelRole,
UncheckedIconRole, CheckedPanelRole, CheckedLabelRole, CheckedIconRole
}
);
}
QRectF MyToggleButtonSkinlet::subControlRect(
@ -44,12 +46,12 @@ QRectF MyToggleButtonSkinlet::subControlRect(
}
else if( subControl == Q::UncheckedPanel )
{
auto rect = innerRect( skinnable, Q::Panel );
const auto rect = innerRect( skinnable, Q::Panel );
return sectionRect( rect, button->isInverted() ? 0 : 1 );
}
else if( subControl == Q::CheckedPanel )
{
auto rect = innerRect( skinnable, Q::Panel );
const auto rect = innerRect( skinnable, Q::Panel );
return sectionRect( rect, button->isInverted() ? 1 : 0 );
}
else if( subControl == Q::CheckedLabel || subControl == Q::CheckedIcon )
@ -100,27 +102,27 @@ QSGNode* MyToggleButtonSkinlet::updateSubNode(
case CheckedLabelRole:
{
return updateTextNode(
button, node, button->textAt( Q::CheckedSection ),
button, node, button->textAt( 1 ),
button->textOptions(), Q::CheckedLabel );
}
case UncheckedLabelRole:
{
return updateTextNode(
button, node, button->textAt( Q::UncheckedSection ),
button, node, button->textAt( 0 ),
button->textOptions(), Q::UncheckedLabel );
}
case CheckedIconRole:
{
return updateGraphicNode(
button, node, button->graphicAt( Q::CheckedSection ), Q::CheckedIcon );
button, node, button->graphicAt( 1 ), Q::CheckedIcon );
}
case UncheckedIconRole:
{
return updateGraphicNode(
button, node, button->graphicAt( Q::UncheckedSection ), Q::UncheckedIcon );
button, node, button->graphicAt( 0 ), Q::UncheckedIcon );
}
case CheckedPanelRole: