Fix 'clear' button position and size on HiDPI

In Locator, find tool bar, options filter etc.

Change-Id: I7f3b0b1ab22e00250dd933e3ac7a4c080eaeebe0
Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
Eike Ziller
2014-04-15 13:01:18 +02:00
parent 5ae3311265
commit 55523dff96
2 changed files with 18 additions and 3 deletions

View File

@@ -216,8 +216,8 @@ void FancyLineEdit::updateMargins()
Side realLeft = (leftToRight ? Left : Right); Side realLeft = (leftToRight ? Left : Right);
Side realRight = (leftToRight ? Right : Left); Side realRight = (leftToRight ? Right : Left);
int leftMargin = d->m_iconbutton[realLeft]->pixmap().width() + 8; int leftMargin = d->m_iconbutton[realLeft]->sizeHint().width() + 8;
int rightMargin = d->m_iconbutton[realRight]->pixmap().width() + 8; int rightMargin = d->m_iconbutton[realRight]->sizeHint().width() + 8;
// Note KDE does not reserve space for the highlight color // Note KDE does not reserve space for the highlight color
if (style()->inherits("OxygenStyle")) { if (style()->inherits("OxygenStyle")) {
leftMargin = qMax(24, leftMargin); leftMargin = qMax(24, leftMargin);
@@ -486,8 +486,12 @@ IconButton::IconButton(QWidget *parent)
void IconButton::paintEvent(QPaintEvent *) void IconButton::paintEvent(QPaintEvent *)
{ {
qreal pixmapRatio = 1.0;
#if QT_VERSION >= 0x050100
pixmapRatio = m_pixmap.devicePixelRatio();
#endif
QStylePainter painter(this); QStylePainter painter(this);
QRect pixmapRect = QRect(0, 0, m_pixmap.width(), m_pixmap.height()); QRect pixmapRect = QRect(0, 0, m_pixmap.width()/pixmapRatio, m_pixmap.height()/pixmapRatio);
pixmapRect.moveCenter(rect().center()); pixmapRect.moveCenter(rect().center());
if (m_autoHide) if (m_autoHide)
@@ -523,6 +527,15 @@ void IconButton::animateShow(bool visible)
} }
} }
QSize IconButton::sizeHint() const
{
qreal pixmapRatio = 1.0;
#if QT_VERSION >= 0x050100
pixmapRatio = m_pixmap.devicePixelRatio();
#endif
return QSize(m_pixmap.width()/pixmapRatio, m_pixmap.height()/pixmapRatio);
}
void IconButton::keyPressEvent(QKeyEvent *ke) void IconButton::keyPressEvent(QKeyEvent *ke)
{ {
QAbstractButton::keyPressEvent(ke); QAbstractButton::keyPressEvent(ke);

View File

@@ -61,6 +61,8 @@ public:
void setAutoHide(bool hide) { m_autoHide = hide; } void setAutoHide(bool hide) { m_autoHide = hide; }
bool hasAutoHide() const { return m_autoHide; } bool hasAutoHide() const { return m_autoHide; }
QSize sizeHint() const;
protected: protected:
void keyPressEvent(QKeyEvent *ke); void keyPressEvent(QKeyEvent *ke);
void keyReleaseEvent(QKeyEvent *ke); void keyReleaseEvent(QKeyEvent *ke);