~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to plasma/netbook/shell/nettoolbox/nettoolbox.h

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *   Copyright 2009 Marco Martin <notmart@gmail.com>
 
3
 *
 
4
 *   This program is free software; you can redistribute it and/or modify
 
5
 *   it under the terms of the GNU Library General Public License as
 
6
 *   published by the Free Software Foundation; either version 2, or
 
7
 *   (at your option) any later version.
 
8
 *
 
9
 *   This program is distributed in the hope that it will be useful,
 
10
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 *   GNU General Public License for more details
 
13
 *
 
14
 *   You should have received a copy of the GNU Library General Public
 
15
 *   License along with this program; if not, write to the
 
16
 *   Free Software Foundation, Inc.,
 
17
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
18
 */
 
19
 
 
20
#ifndef NETTOOLBOX_H
 
21
#define NETTOOLBOX_H
 
22
 
 
23
#include <QGraphicsWidget>
 
24
#include <QPropertyAnimation>
 
25
#include <KIcon>
 
26
 
 
27
#include <plasma/abstracttoolbox.h>
 
28
#include <plasma/containment.h>
 
29
 
 
30
 
 
31
class QGraphicsLinearLayout;
 
32
 
 
33
namespace Plasma
 
34
{
 
35
    class Containment;
 
36
    class IconWidget;
 
37
    class Svg;
 
38
}
 
39
 
 
40
class ToolContainer;
 
41
 
 
42
class NetToolBox : public Plasma::AbstractToolBox
 
43
{
 
44
    Q_OBJECT
 
45
    Q_PROPERTY(bool showing READ isShowing WRITE setShowing )
 
46
    Q_PROPERTY(qreal highlight READ highlight WRITE setHighlight)
 
47
public:
 
48
    explicit NetToolBox(Plasma::Containment *parent = 0);
 
49
    explicit NetToolBox(QObject *parent, const QVariantList &args);
 
50
    ~NetToolBox();
 
51
 
 
52
    bool isShowing() const;
 
53
    void setShowing(const bool show);
 
54
 
 
55
    /**
 
56
     * create a toolbox tool from the given action
 
57
     * @p action the action to associate the tool with
 
58
     */
 
59
    void addTool(QAction *action);
 
60
    /**
 
61
     * remove the tool associated with this action
 
62
     */
 
63
    void removeTool(QAction *action);
 
64
 
 
65
    QRectF expandedGeometry() const;
 
66
 
 
67
    void setLocation(Plasma::Location location);
 
68
    Plasma::Location location() const;
 
69
 
 
70
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
 
71
 
 
72
protected:
 
73
    void init();
 
74
 
 
75
    void mousePressEvent(QGraphicsSceneMouseEvent *event);
 
76
    void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
 
77
    void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
 
78
    void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
 
79
    bool eventFilter(QObject *watched, QEvent *event);
 
80
 
 
81
private Q_SLOTS:
 
82
    void containmentGeometryChanged();
 
83
    void setHighlight(qreal progress);
 
84
    qreal highlight();
 
85
    void movementFinished();
 
86
    void onMovement(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
 
87
 
 
88
private:
 
89
    void highlight(bool highlighting);
 
90
    ToolContainer *m_toolContainer;
 
91
    QGraphicsLinearLayout *m_toolContainerLayout;
 
92
    QHash<QAction *, Plasma::IconWidget *> m_actionButtons;
 
93
    Plasma::Containment *m_containment;
 
94
    Plasma::Svg *m_background;
 
95
    KIcon m_icon;
 
96
    KIcon m_closeIcon;
 
97
    QSize m_iconSize;
 
98
    Plasma::Animation *slideAnim;
 
99
    QPropertyAnimation *anim;
 
100
    qreal m_animHighlightFrame;
 
101
    bool m_hovering;
 
102
    bool m_showing;
 
103
    Plasma::Location m_location;
 
104
    int m_newToolsPosition;
 
105
};
 
106
 
 
107
K_EXPORT_PLASMA_TOOLBOX(nettoolbox, NetToolBox)
 
108
 
 
109
#endif