~ubuntu-branches/ubuntu/lucid/kdebase/lucid

« back to all changes in this revision

Viewing changes to apps/plasma/applets/folderview/actionoverlay.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Alessandro Ghersi
  • Date: 2009-12-19 18:29:39 UTC
  • mfrom: (1.1.36 upstream)
  • Revision ID: james.westby@ubuntu.com-20091219182939-i4q5c16348k7vxuk
Tags: 4:4.3.85-0ubuntu1
* New upstream release
  - Bump build-deps

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
#include <Plasma/PaintUtils>
24
24
#include <Plasma/Animator>
25
 
#include <Plasma/Svg>                                                
 
25
#include <Plasma/Svg>
26
26
 
27
27
#include <QPainter>
28
28
#include <QGraphicsGridLayout>
29
29
 
30
30
ActionIcon::ActionIcon(QGraphicsItem* parent)
31
 
    : QGraphicsWidget(parent),                                       
32
 
      m_pressed(false),                                              
33
 
      m_sunken(false)                                                
 
31
    : QGraphicsWidget(parent),
 
32
      m_pressed(false),
 
33
      m_sunken(false)
34
34
{
35
35
    setAcceptHoverEvents(true);
36
36
    setCacheMode(DeviceCoordinateCache);
37
 
                                                                     
38
 
    m_icon = new Plasma::Svg(this);                                  
39
 
    m_icon->setImagePath("widgets/action-overlays");                 
40
 
    m_icon->setContainsMultipleImages(true);                         
41
 
                                                                     
42
 
    setMinimumSize(m_icon->elementSize("add-normal"));               
43
 
    setMaximumSize(minimumSize());                                   
44
 
                                                                     
 
37
 
 
38
    m_icon = new Plasma::Svg(this);
 
39
    m_icon->setImagePath("widgets/action-overlays");
 
40
    m_icon->setContainsMultipleImages(true);
 
41
 
 
42
    setMinimumSize(m_icon->elementSize("add-normal"));
 
43
    setMaximumSize(minimumSize());
 
44
 
45
45
    show();
46
46
}
47
47
 
51
51
    QPersistentModelIndex index = static_cast<ActionOverlay*>(parentWidget())->hoverIndex();
52
52
    QItemSelectionModel *m_selectionModel = view->selectionModel();
53
53
 
54
 
    QString element = m_selectionModel->isSelected(index) ? "remove" : "add";               
55
 
    if (m_sunken) {                                                                         
56
 
        element += "-pressed";                                                              
57
 
    } else if (isUnderMouse()) {                                                            
58
 
        element += "-hover";                                                                
59
 
    } else {                                                                                
60
 
        element += "-normal";                                                               
61
 
    }                                                                                       
62
 
    m_icon->paint(painter, rect(), element);                                                
 
54
    QString element = m_selectionModel->isSelected(index) ? "remove" : "add";
 
55
    if (m_sunken) {
 
56
        element += "-pressed";
 
57
    } else if (isUnderMouse()) {
 
58
        element += "-hover";
 
59
    } else {
 
60
        element += "-normal";
 
61
    }
 
62
    m_icon->paint(painter, rect(), element);
63
63
}
64
64
 
65
65
void ActionIcon::mousePressEvent(QGraphicsSceneMouseEvent* event)
188
188
    // allow the animation to restart after hiding the ActionOverlayIcon even if m_hoverIndex didn't change
189
189
    m_hoverIndex = QPersistentModelIndex();
190
190
 
191
 
    if (isVisible() && (!fadeOut->animation() || fadeOut->animation()->state() != QAbstractAnimation::Running)) {
 
191
    if (isVisible() && (fadeOut->state() != QAbstractAnimation::Running)) {
192
192
        fadeOut->start();
193
 
        connect(fadeOut->animation(), SIGNAL(finished()), SLOT(close()));
 
193
        connect(fadeOut, SIGNAL(finished()), SLOT(close()));
194
194
    }
195
195
}
196
196