┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/views/selectiontoggle.cpp
diff options
context:
space:
mode:
authorPeter Penz <[email protected]>2010-09-22 19:12:09 +0000
committerPeter Penz <[email protected]>2010-09-22 19:12:09 +0000
commitabefc8663ac5c9dc15ad08408e224b3a3cef3b6f (patch)
tree92907c9753ab9ec2718e2eb78531a6c984ffb8cd /src/views/selectiontoggle.cpp
parent5517e4cf10c8aee590b404072aebaffb55bafec3 (diff)
Add a small invisible margin to the selection toggle in case the item-height is nearly equal to the toggle-height. This prevents an accidental execution of application in the details-view with the default icon-size.
BUG: 169494 FIXED-IN: 4.6.0 svn path=/trunk/KDE/kdebase/apps/; revision=1178332
Diffstat (limited to 'src/views/selectiontoggle.cpp')
-rw-r--r--src/views/selectiontoggle.cpp25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/views/selectiontoggle.cpp b/src/views/selectiontoggle.cpp
index d802e22e0..f5287a3dd 100644
--- a/src/views/selectiontoggle.cpp
+++ b/src/views/selectiontoggle.cpp
@@ -36,6 +36,7 @@ SelectionToggle::SelectionToggle(QWidget* parent) :
m_isHovered(false),
m_leftMouseButtonPressed(false),
m_fadingValue(0),
+ m_margin(0),
m_icon(),
m_fadingTimeLine(0)
{
@@ -72,6 +73,19 @@ void SelectionToggle::setUrl(const KUrl& url)
}
}
+void SelectionToggle::setMargin(int margin)
+{
+ if (margin != m_margin) {
+ m_margin = margin;
+ update();
+ }
+}
+
+int SelectionToggle::margin() const
+{
+ return m_margin;
+}
+
KUrl SelectionToggle::url() const
{
return m_url;
@@ -161,10 +175,11 @@ void SelectionToggle::paintEvent(QPaintEvent* event)
painter.setClipRect(event->rect());
// draw the icon overlay
+ const QPoint pos(m_margin, m_margin);
if (m_isHovered) {
KIconEffect *iconEffect = KIconLoader::global()->iconEffect();
QPixmap activeIcon = iconEffect->apply(m_icon, KIconLoader::Desktop, KIconLoader::ActiveState);
- painter.drawPixmap(0, 0, activeIcon);
+ painter.drawPixmap(pos, activeIcon);
} else {
if (m_fadingValue < 255) {
// apply an alpha mask respecting the fading value to the icon
@@ -173,12 +188,13 @@ void SelectionToggle::paintEvent(QPaintEvent* event)
const QColor color(m_fadingValue, m_fadingValue, m_fadingValue);
alphaMask.fill(color);
icon.setAlphaChannel(alphaMask);
- painter.drawPixmap(0, 0, icon);
+ painter.drawPixmap(pos, icon);
} else {
// no fading is required
- painter.drawPixmap(0, 0, m_icon);
+ painter.drawPixmap(pos, m_icon);
}
}
+
}
void SelectionToggle::setFadingValue(int value)
@@ -194,9 +210,10 @@ void SelectionToggle::setFadingValue(int value)
void SelectionToggle::setIconOverlay(bool checked)
{
const char* icon = checked ? "list-remove" : "list-add";
+ const int size = qMin(width() - 2 * m_margin, height() - 2 * m_margin);
m_icon = KIconLoader::global()->loadIcon(icon,
KIconLoader::NoGroup,
- qMin(width(), height()));
+ size);
update();
}