]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/IconPalette.h
* Get rid the of the QWidgetAction subclass and use homebrew tearoff widget:
[lyx.git] / src / frontends / qt4 / IconPalette.h
1 // -*- C++ -*-
2 /**
3  * \file IconPalette.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Edwin Leuven
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef ICONPALETTE_H
13 #define ICONPALETTE_H
14
15 #include <QWidget>
16 #include <QMenu>
17 #include <QLayout>
18 #include "Action.h"
19
20
21 namespace lyx {
22 namespace frontend {
23
24 /**
25   * tear-off widget
26   */
27 class TearOff : public QWidget {
28         Q_OBJECT
29 public:
30         TearOff(QWidget * parent);
31         void enterEvent(QEvent *);
32         void leaveEvent(QEvent *);
33         void mouseReleaseEvent (QMouseEvent *);
34 Q_SIGNALS:
35         void tearOff();
36 protected:
37         void paintEvent(QPaintEvent *);
38 private:
39         bool highlighted_;
40 };
41
42
43 /**
44  * For holding an arbitrary set of icons.
45  */
46 class IconPalette : public QWidget {
47         Q_OBJECT
48 public:
49         IconPalette(QWidget * parent);
50         void addButton(QAction *);
51
52 public Q_SLOTS:
53         void updateParent();
54
55 Q_SIGNALS:
56         void triggered(QAction *);
57         void visible(bool);
58
59 protected:
60         void showEvent(QShowEvent * event);
61         void hideEvent(QHideEvent * event);
62         void paintEvent(QPaintEvent * event);
63
64 private Q_SLOTS:
65         void tearOff();
66         virtual void clicked(QAction *);
67
68 private:
69         QGridLayout * layout_;
70         QList<QAction *> actions_;
71         bool tornoff_;
72         TearOff * tearoffwidget_; 
73 };
74
75
76 /**
77  * Popup menu for a toolbutton.
78  * We need this to keep track whether
79  * it is necessary to enable/disable
80  * the toolbutton
81  */
82 class ButtonMenu : public QMenu {
83         Q_OBJECT
84 public:
85         ButtonMenu(const QString & title, QWidget * parent = 0 );
86         void add(QAction *);
87
88 public Q_SLOTS:
89         void updateParent();
90
91 private:
92         QList<QAction *> actions_;
93 };
94
95
96 } // namespace frontend
97 } // namespace lyx
98
99 #endif // ICONPALETTE_H