Revert "QskPushButton: respect the graphics alignment"

This reverts commit 3c69498026.
This commit is contained in:
Peter Hartmann 2022-06-15 10:57:36 +02:00
parent 4aa0c7de79
commit 8ee681588e
3 changed files with 13 additions and 63 deletions

View File

@ -489,7 +489,6 @@ void Editor::setupPushButton()
setColor( Q::Text | Q::Disabled, c1, combination );
setAnimation( Q::Panel | A::Color, qskDuration );
setAnimation( Q::Panel | A::Metric, qskDuration );
setAnimation( Q::Text | A::Color, qskDuration );

View File

@ -594,9 +594,6 @@ void Editor::setupPushButton()
setColor( Q::Text, m_pal.themeForeground );
setColor( Q::Text | Q::Disabled, m_pal.darker200 );
// Graphic
setPadding( Q::Graphic, 2 );
}
void Editor::setupDialogButton()

View File

@ -77,25 +77,12 @@ QRectF QskPushButtonSkinlet::textRect(
if ( button->hasGraphic() )
{
const auto alignment = button->alignmentHint( QskPushButton::Graphic, Qt::AlignTop );
// in case of having text + graphic we put the text at the bottom
switch( alignment )
{
case Qt::AlignLeft:
{
const auto graphicsRect = subControlRect( button, contentsRect, QskPushButton::Graphic );
const auto spacing = button->metric( QskPushButton::Panel | QskAspect::Spacing );
r.setX( r.x() + graphicsRect.width() + spacing );
break;
}
default: // AlignTop
{
qreal h = QFontMetricsF( button->effectiveFont( QskPushButton::Text ) ).height();
qreal h = button->effectiveFontHeight( QskPushButton::Text );
if ( h < r.height() )
r.setTop( r.bottom() - h );
}
}
}
return r;
}
@ -107,9 +94,7 @@ QRectF QskPushButtonSkinlet::graphicRect(
auto r = button->subControlContentsRect( contentsRect, QskPushButton::Panel );
const auto alignment = button->alignmentHint( QskPushButton::Graphic, Qt::AlignTop );
if ( !button->text().isEmpty() && alignment != Qt::AlignLeft )
if ( !button->text().isEmpty() )
{
const auto textRect = subControlRect( button, contentsRect, QskPushButton::Text );
qreal h = textRect.height() + button->spacingHint( QskPushButton::Panel );
@ -121,7 +106,6 @@ QRectF QskPushButtonSkinlet::graphicRect(
}
const auto maxSize = button->graphicSourceSize();
if ( maxSize.width() >= 0 || maxSize.height() >= 0 )
{
// limiting the size by graphicSize
@ -150,31 +134,15 @@ QRectF QskPushButtonSkinlet::graphicRect(
const double scaleFactor =
qMin( r.width() / sz.width(), r.height() / sz.height() );
const int w = qFloor( scaleFactor * sz.width() );
const int h = qFloor( scaleFactor * sz.height() );
int x, y;
switch( alignment )
{
case Qt::AlignLeft:
{
x = r.left();
y = r.top();
break;
}
default: // AlignTop
{
// early aligning to avoid pointless operations, that finally will
// have no effect, when drawing to an integer based paint device
x = qFloor( r.center().x() - 0.5 * w );
y = qFloor( r.center().y() - 0.5 * h );
}
}
const int w = qFloor( scaleFactor * sz.width() );
const int h = qFloor( scaleFactor * sz.height() );
const int x = qFloor( r.center().x() - 0.5 * w );
const int y = qFloor( r.center().y() - 0.5 * h );
r = QRectF( x, y, w, h );
const auto padding = button->paddingHint( QskPushButton::Graphic );
r = r.marginsRemoved( padding );
}
return r;
@ -245,25 +213,11 @@ QSizeF QskPushButtonSkinlet::sizeHint( const QskSkinnable* skinnable,
}
}
const auto alignment = button->alignmentHint( QskPushButton::Graphic, Qt::AlignTop );
const qreal padding = 2.0; // paddingHint( Graphic ) ???
const QMarginsF padding = button->paddingHint( QskPushButton::Graphic );
switch( alignment )
{
case Qt::AlignLeft:
{
size.rwidth() += padding.left() + w + padding.right();
size.rheight() = qMax( size.height(), h );
break;
}
default: // AlignTop
{
size.rheight() += padding.top() + h + padding.bottom();
size.rheight() += 2 * padding + h;
size.rwidth() = qMax( size.width(), w );
}
}
}
size = size.expandedTo( button->strutSizeHint( QskPushButton::Panel ) );
size = button->outerBoxSize( QskPushButton::Panel, size );