~ubuntu-branches/ubuntu/karmic/psi/karmic

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*
 * iconaction.h - the QAction subclass that uses Icons and supports animation
 * Copyright (C) 2003-2005  Michail Pishchagin
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */

#ifndef ICONACTION_H
#define ICONACTION_H

#include <QAction>
#include <QList>

class QToolButton;
class QPixmap;
class QIcon;
class PsiIcon;
class IconToolButton;
class QChildEvent;

class IconAction : public QAction
{
	Q_OBJECT
public:
	IconAction(QObject *parent, const QString &name = QString());
	IconAction(const QString &statusTip, const QString &icon, const QString &text, QKeySequence accel, QObject *parent, const QString &name = QString(), bool checkable = FALSE);
	IconAction(const QString &statusTip, const QString &text, QKeySequence accel, QObject *parent, const QString &name = QString(), bool checkable = FALSE);
	~IconAction();

	virtual bool addTo(QWidget *);

	const PsiIcon *psiIcon() const;
	void setPsiIcon(const PsiIcon *);
	void setPsiIcon(const QString &);
	QString psiIconName() const;

	void setMenu( QMenu * );

	void setIcon( const QIcon & );
	void setVisible( bool );

	virtual IconAction *copy() const;
	virtual IconAction &operator=( const IconAction & );

public slots:
	void setEnabled(bool);
	void setChecked(bool);
	void setText(const QString &);

protected:
	virtual void doSetMenu(QMenu* menu);
	virtual void addingToolButton(IconToolButton *) { }
	//virtual void addingMenuItem(QPopupMenu *, int id) { Q_UNUSED(id); }
	QList<IconToolButton *> buttonList();

	QString toolTipFromMenuText() const;

private slots:
	void objectDestroyed();
	void iconUpdated();
	void toolButtonToggled(bool);

public:
	class Private;
private:
	Private *d;
	friend class Private;
};

class IconActionGroup : public IconAction
{
	Q_OBJECT
public:
	IconActionGroup(QObject *parent, const char *name = 0, bool exclusive = false);
	~IconActionGroup();

	void setExclusive( bool );
	bool isExclusive() const;

	void add( QAction * );
	void addSeparator();

	bool addTo( QWidget * );

	void setUsesDropDown( bool );
	bool usesDropDown() const;

	void childEvent(QChildEvent *);

	void addingToolButton(IconToolButton *);

	IconAction *copy() const;

public:
	class Private;
private:
	Private *d;
	friend class Private;
};

#endif