Commit 5f2bf2fa authored by Gilles Caulier's avatar Gilles Caulier 🗼
Browse files

backport commit #99648053 from git/master to frameworks branch

CCBUGS: 261568
parent 75f477a2
......@@ -45,7 +45,7 @@ ImageRotateOverlayButton::ImageRotateOverlayButton(ImageRotateOverlayDirection d
QSize ImageRotateOverlayButton::sizeHint() const
{
return QSize(16, 16);
return QSize(32, 32);
}
QIcon ImageRotateOverlayButton::icon()
......@@ -101,9 +101,11 @@ ItemViewHoverButton* ImageRotateOverlay::createButton()
void ImageRotateOverlay::updateButton(const QModelIndex& index)
{
const QRect rect = m_view->visualRect(index);
const int size = qBound(16, rect.width() / 8 - 2, 48);
const int gap = 5;
const int x = rect.right() - 2*gap - (isLeft() ? 16*3 + 2 : 16*2 +2);
const int x = rect.right() - 2*gap - (isLeft() ? size*3 + 2 : size*2 + 2);
const int y = rect.top() + gap;
button()->resize(size, size);
button()->move(QPoint(x, y));
}
......
......@@ -43,7 +43,7 @@ ImageSelectionOverlayButton::ImageSelectionOverlayButton(QAbstractItemView* pare
QSize ImageSelectionOverlayButton::sizeHint() const
{
return QSize(16, 16);
return QSize(32, 32);
}
QIcon ImageSelectionOverlayButton::icon()
......@@ -96,9 +96,11 @@ ItemViewHoverButton* ImageSelectionOverlay::createButton()
void ImageSelectionOverlay::updateButton(const QModelIndex& index)
{
const QRect rect = m_view->visualRect(index);
const int size = qBound(16, rect.width() / 8 - 2, 48);
const int gap = 5;
const int x = rect.left() + gap;
const int y = rect.top() + gap;
button()->resize(size, size);
button()->move(QPoint(x, y));
QItemSelectionModel* const selModel = m_view->selectionModel();
......
......@@ -146,18 +146,18 @@ void ItemViewHoverButton::paintEvent(QPaintEvent* event)
painter.drawEllipse(0, 0, width(), height());
// draw the icon overlay
QPixmap icon = m_icon.pixmap(width() - 2, height() - 2);
if (m_isHovered)
{
// FIXME; see bugs #261568 about hardcoded pixmap sizes
QPixmap activeIcon = m_icon.pixmap(48);
painter.drawPixmap(0, 0, activeIcon);
QPixmap activeIcon = icon.scaled(48, 48);
painter.drawPixmap(1, 1, activeIcon);
}
else
{
if (m_fadingValue < 255)
{
// apply an alpha mask respecting the fading value to the icon
QPixmap icon = m_icon.pixmap(style()->pixelMetric(QStyle::PM_SmallIconSize));
QPixmap alphaMask(icon.width(), icon.height());
const QColor color(m_fadingValue, m_fadingValue, m_fadingValue);
alphaMask.fill(color);
......@@ -170,12 +170,12 @@ void ItemViewHoverButton::paintEvent(QPaintEvent* event)
p.drawPixmap(0, 0, alphaMask);
p.end();
painter.drawPixmap(0, 0, icon);
painter.drawPixmap(1, 1, icon);
}
else
{
// no fading is required
painter.drawPixmap(0, 0, m_icon.pixmap(style()->pixelMetric(QStyle::PM_SmallIconSize)));
painter.drawPixmap(1, 1, icon);
}
}
}
......
......@@ -413,7 +413,7 @@ ImportRotateOverlayButton::ImportRotateOverlayButton(ImportRotateOverlayDirectio
QSize ImportRotateOverlayButton::sizeHint() const
{
return QSize(16, 16);
return QSize(32, 32);
}
QIcon ImportRotateOverlayButton::icon()
......@@ -467,9 +467,11 @@ ItemViewHoverButton* ImportRotateOverlay::createButton()
void ImportRotateOverlay::updateButton(const QModelIndex& index)
{
const QRect rect = m_view->visualRect(index);
const int size = qBound(16, rect.width() / 8 - 2, 48);
const int gap = 5;
const int x = rect.right() - 2*gap - (isLeft() ? 16*5 + 2 : 16*4 +2);
const int x = rect.right() - 2*gap - (isLeft() ? size*5 + 2 : size*4 + 2);
const int y = rect.top() + gap;
button()->resize(size, size);
button()->move(QPoint(x, y));
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment