1 | /**************************************************************************** |
2 | ** |
3 | ** Copyright (C) 2007-2008 Urs Wolfer <uwolfer @ kde.org> |
4 | ** Parts of this file have been take from okular: |
5 | ** Copyright (C) 2004-2005 Enrico Ros <eros.kde@email.it> |
6 | ** |
7 | ** This file is part of KDE. |
8 | ** |
9 | ** This program is free software; you can redistribute it and/or modify |
10 | ** it under the terms of the GNU General Public License as published by |
11 | ** the Free Software Foundation; either version 2 of the License, or |
12 | ** (at your option) any later version. |
13 | ** |
14 | ** This program is distributed in the hope that it will be useful, |
15 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 | ** GNU General Public License for more details. |
18 | ** |
19 | ** You should have received a copy of the GNU General Public License |
20 | ** along with this program; see the file COPYING. If not, write to |
21 | ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
22 | ** Boston, MA 02110-1301, USA. |
23 | ** |
24 | ****************************************************************************/ |
25 | |
26 | #ifndef FLOATINGTOOLBAR_H |
27 | #define FLOATINGTOOLBAR_H |
28 | |
29 | #include <QToolBar> |
30 | |
31 | /** |
32 | * @short A toolbar widget that slides in from a side. |
33 | * |
34 | * This is a shaped widget that slides in from a side of the 'anchor widget' |
35 | * it's attached to. It can be dragged and docked on {left,top,right,bottom} |
36 | * sides and contains actions. |
37 | */ |
38 | class FloatingToolBar : public QToolBar |
39 | { |
40 | Q_OBJECT |
41 | public: |
42 | FloatingToolBar(QWidget *parent, QWidget *anchorWidget); |
43 | ~FloatingToolBar(); |
44 | |
45 | Q_ENUMS(Side) |
46 | enum Side { Left = 0, Top = 1, Right = 2, Bottom = 3 }; |
47 | |
48 | void addAction(QAction *action); |
49 | void setSide(Side side); |
50 | |
51 | Q_SIGNALS: |
52 | void orientationChanged(int side); |
53 | |
54 | public Q_SLOTS: |
55 | void setSticky(bool sticky); |
56 | void showAndAnimate(); |
57 | void hideAndDestroy(); |
58 | |
59 | protected: |
60 | bool eventFilter(QObject *o, QEvent *e); |
61 | void paintEvent(QPaintEvent *); |
62 | void mousePressEvent(QMouseEvent *e); |
63 | void mouseMoveEvent(QMouseEvent *e); |
64 | void enterEvent(QEvent *e); |
65 | void leaveEvent(QEvent *e); |
66 | void mouseReleaseEvent(QMouseEvent *e); |
67 | void wheelEvent(QWheelEvent *e); |
68 | |
69 | private: |
70 | class FloatingToolBarPrivate *d; |
71 | |
72 | private Q_SLOTS: |
73 | void animate(); |
74 | void hide(); |
75 | }; |
76 | |
77 | #endif |
78 | |