| 1 | /*
|
|---|
| 2 | * iconaction.h - the QAction subclass that uses Icons and supports animation
|
|---|
| 3 | * Copyright (C) 2003-2004 Michail Pishchagin
|
|---|
| 4 | *
|
|---|
| 5 | * This library is free software; you can redistribute it and/or
|
|---|
| 6 | * modify it under the terms of the GNU Lesser General Public
|
|---|
| 7 | * License as published by the Free Software Foundation; either
|
|---|
| 8 | * version 2.1 of the License, or (at your option) any later version.
|
|---|
| 9 | *
|
|---|
| 10 | * This library is distributed in the hope that it will be useful,
|
|---|
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|---|
| 13 | * Lesser General Public License for more details.
|
|---|
| 14 | *
|
|---|
| 15 | * You should have received a copy of the GNU Lesser General Public
|
|---|
| 16 | * License along with this library; if not, write to the Free Software
|
|---|
| 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|---|
| 18 | *
|
|---|
| 19 | */
|
|---|
| 20 |
|
|---|
| 21 | #ifndef ICONACTION_H
|
|---|
| 22 | #define ICONACTION_H
|
|---|
| 23 |
|
|---|
| 24 | #include <qaction.h>
|
|---|
| 25 | #include <qptrlist.h>
|
|---|
| 26 |
|
|---|
| 27 | class QToolButton;
|
|---|
| 28 | class QPixmap;
|
|---|
| 29 | class QIconSet;
|
|---|
| 30 | class Icon;
|
|---|
| 31 | class IconToolButton;
|
|---|
| 32 |
|
|---|
| 33 | class IconAction : public QAction
|
|---|
| 34 | {
|
|---|
| 35 | Q_OBJECT
|
|---|
| 36 | public:
|
|---|
| 37 | IconAction(QObject *parent, const char *name = 0);
|
|---|
| 38 | IconAction(const QString &text, const QString &icon, const QString &menuText, QKeySequence accel, QObject *parent, const char *name = 0, bool toggle = FALSE);
|
|---|
| 39 | IconAction(const QString &text, const QString &menuText, QKeySequence accel, QObject *parent, const char *name = 0, bool toggle = FALSE);
|
|---|
| 40 | ~IconAction();
|
|---|
| 41 |
|
|---|
| 42 | virtual bool addTo(QWidget *);
|
|---|
| 43 |
|
|---|
| 44 | const Icon *icon() const;
|
|---|
| 45 | void setIcon(const Icon *);
|
|---|
| 46 | void setIcon(const QString &);
|
|---|
| 47 | const QString &iconName() const;
|
|---|
| 48 |
|
|---|
| 49 | QPopupMenu *popup() const;
|
|---|
| 50 | void setPopup( QPopupMenu * );
|
|---|
| 51 |
|
|---|
| 52 | void setIconSet( const QIconSet & );
|
|---|
| 53 | void setVisible( bool );
|
|---|
| 54 |
|
|---|
| 55 | virtual IconAction *copy() const;
|
|---|
| 56 | virtual IconAction &operator=( const IconAction & );
|
|---|
| 57 |
|
|---|
| 58 | public slots:
|
|---|
| 59 | void setEnabled(bool);
|
|---|
| 60 | void setOn(bool);
|
|---|
| 61 | void setText(const QString &);
|
|---|
| 62 |
|
|---|
| 63 | protected:
|
|---|
| 64 | virtual void addingToolButton(IconToolButton *) { }
|
|---|
| 65 | virtual void addingMenuItem(QPopupMenu *, int id) { Q_UNUSED(id); }
|
|---|
| 66 | QPtrList<IconToolButton> buttonList();
|
|---|
| 67 |
|
|---|
| 68 | QString toolTipFromMenuText() const;
|
|---|
| 69 |
|
|---|
| 70 | private slots:
|
|---|
| 71 | void objectDestroyed();
|
|---|
| 72 | void iconUpdated(const QPixmap &);
|
|---|
| 73 | void toolButtonToggled(bool);
|
|---|
| 74 |
|
|---|
| 75 | public:
|
|---|
| 76 | class Private;
|
|---|
| 77 | private:
|
|---|
| 78 | Private *d;
|
|---|
| 79 | friend class Private;
|
|---|
| 80 | };
|
|---|
| 81 |
|
|---|
| 82 | class IconActionGroup : public IconAction
|
|---|
| 83 | {
|
|---|
| 84 | Q_OBJECT
|
|---|
| 85 | public:
|
|---|
| 86 | IconActionGroup(QObject *parent, const char *name = 0, bool exclusive = false);
|
|---|
| 87 | ~IconActionGroup();
|
|---|
| 88 |
|
|---|
| 89 | void setExclusive( bool );
|
|---|
| 90 | bool isExclusive() const;
|
|---|
| 91 |
|
|---|
| 92 | void add( QAction * );
|
|---|
| 93 | void addSeparator();
|
|---|
| 94 |
|
|---|
| 95 | bool addTo( QWidget * );
|
|---|
| 96 |
|
|---|
| 97 | void setUsesDropDown( bool );
|
|---|
| 98 | bool usesDropDown() const;
|
|---|
| 99 |
|
|---|
| 100 | void insertChild( QObject * );
|
|---|
| 101 | void removeChild( QObject * );
|
|---|
| 102 |
|
|---|
| 103 | void addingToolButton(IconToolButton *);
|
|---|
| 104 |
|
|---|
| 105 | IconAction *copy() const;
|
|---|
| 106 |
|
|---|
| 107 | public:
|
|---|
| 108 | class Private;
|
|---|
| 109 | private:
|
|---|
| 110 | Private *d;
|
|---|
| 111 | friend class Private;
|
|---|
| 112 | };
|
|---|
| 113 |
|
|---|
| 114 | #endif
|
|---|