avoid temporaries in QCleanlooksStyle::drawControl()

Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
Ivailo Monev 2020-07-01 14:26:43 +00:00
parent 40b80d3796
commit 8e1bd44ce1

View file

@ -2053,9 +2053,6 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o
tf |= Qt::TextHideMnemonic; tf |= Qt::TextHideMnemonic;
if (!button->icon.isNull()) { if (!button->icon.isNull()) {
//Center both icon and text
QPoint point;
QIcon::Mode mode = button->state & State_Enabled ? QIcon::Normal QIcon::Mode mode = button->state & State_Enabled ? QIcon::Normal
: QIcon::Disabled; : QIcon::Disabled;
if (mode == QIcon::Normal && button->state & State_HasFocus) if (mode == QIcon::Normal && button->state & State_HasFocus)
@ -2071,7 +2068,8 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o
if (!button->text.isEmpty()) if (!button->text.isEmpty())
w += button->fontMetrics.boundingRect(option->rect, tf, button->text).width() + 2; w += button->fontMetrics.boundingRect(option->rect, tf, button->text).width() + 2;
point = QPoint(ir.x() + ir.width() / 2 - w / 2, // center both icon and text
QPoint point(ir.x() + ir.width() / 2 - w / 2,
ir.y() + ir.height() / 2 - h / 2); ir.y() + ir.height() / 2 - h / 2);
if (button->direction == Qt::RightToLeft) if (button->direction == Qt::RightToLeft)
@ -2164,11 +2162,10 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o
int borderThinkness = proxy()->pixelMetric(PM_TabBarBaseOverlap, tab, widget); int borderThinkness = proxy()->pixelMetric(PM_TabBarBaseOverlap, tab, widget);
if (selected) if (selected)
borderThinkness /= 2; borderThinkness /= 2;
QRect r2(option->rect); int x1 = option->rect.left();
int x1 = r2.left(); int x2 = option->rect.right();
int x2 = r2.right(); int y1 = option->rect.top();
int y1 = r2.top(); int y2 = option->rect.bottom();
int y2 = r2.bottom();
QTransform rotMatrix; QTransform rotMatrix;
bool flip = false; bool flip = false;
@ -2202,8 +2199,7 @@ void QCleanlooksStyle::drawControl(ControlElement element, const QStyleOption *o
} }
if (flip) { if (flip) {
QRect tmp = rect; rect = QRect(rect.y(), rect.x(), rect.height(), rect.width());
rect = QRect(tmp.y(), tmp.x(), tmp.height(), tmp.width());
int temp = x1; int temp = x1;
x1 = y1; x1 = y1;
y1 = temp; y1 = temp;