| 1 | /****************************************************************************
|
|---|
| 2 | ** $Id: qaction.h 2 2005-11-16 15:49:26Z dmik $
|
|---|
| 3 | **
|
|---|
| 4 | ** Definition of QAction class
|
|---|
| 5 | **
|
|---|
| 6 | ** Created : 000000
|
|---|
| 7 | **
|
|---|
| 8 | ** Copyright (C) 2000 Trolltech AS. All rights reserved.
|
|---|
| 9 | **
|
|---|
| 10 | ** This file is part of the widgets module of the Qt GUI Toolkit.
|
|---|
| 11 | **
|
|---|
| 12 | ** This file may be distributed under the terms of the Q Public License
|
|---|
| 13 | ** as defined by Trolltech AS of Norway and appearing in the file
|
|---|
| 14 | ** LICENSE.QPL included in the packaging of this file.
|
|---|
| 15 | **
|
|---|
| 16 | ** This file may be distributed and/or modified under the terms of the
|
|---|
| 17 | ** GNU General Public License version 2 as published by the Free Software
|
|---|
| 18 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
|---|
| 19 | ** packaging of this file.
|
|---|
| 20 | **
|
|---|
| 21 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
|
|---|
| 22 | ** licenses may use this file in accordance with the Qt Commercial License
|
|---|
| 23 | ** Agreement provided with the Software.
|
|---|
| 24 | **
|
|---|
| 25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
|---|
| 26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
|---|
| 27 | **
|
|---|
| 28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
|---|
| 29 | ** information about Qt Commercial License Agreements.
|
|---|
| 30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information.
|
|---|
| 31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
|---|
| 32 | **
|
|---|
| 33 | ** Contact info@trolltech.com if any conditions of this licensing are
|
|---|
| 34 | ** not clear to you.
|
|---|
| 35 | **
|
|---|
| 36 | **********************************************************************/
|
|---|
| 37 |
|
|---|
| 38 | #ifndef QACTION_H
|
|---|
| 39 | #define QACTION_H
|
|---|
| 40 |
|
|---|
| 41 | #ifndef QT_H
|
|---|
| 42 | #include "qobject.h"
|
|---|
| 43 | #include "qiconset.h"
|
|---|
| 44 | #include "qstring.h"
|
|---|
| 45 | #include "qkeysequence.h"
|
|---|
| 46 | #endif // QT_H
|
|---|
| 47 |
|
|---|
| 48 | #ifndef QT_NO_ACTION
|
|---|
| 49 |
|
|---|
| 50 | class QActionPrivate;
|
|---|
| 51 | class QActionGroupPrivate;
|
|---|
| 52 | class QStatusBar;
|
|---|
| 53 | class QPopupMenu;
|
|---|
| 54 | class QToolTipGroup;
|
|---|
| 55 |
|
|---|
| 56 | class Q_EXPORT QAction : public QObject
|
|---|
| 57 | {
|
|---|
| 58 | Q_OBJECT
|
|---|
| 59 | Q_PROPERTY( bool toggleAction READ isToggleAction WRITE setToggleAction)
|
|---|
| 60 | Q_PROPERTY( bool on READ isOn WRITE setOn )
|
|---|
| 61 | Q_PROPERTY( bool enabled READ isEnabled WRITE setEnabled )
|
|---|
| 62 | Q_PROPERTY( QIconSet iconSet READ iconSet WRITE setIconSet )
|
|---|
| 63 | Q_PROPERTY( QString text READ text WRITE setText )
|
|---|
| 64 | Q_PROPERTY( QString menuText READ menuText WRITE setMenuText )
|
|---|
| 65 | Q_PROPERTY( QString toolTip READ toolTip WRITE setToolTip )
|
|---|
| 66 | Q_PROPERTY( QString statusTip READ statusTip WRITE setStatusTip )
|
|---|
| 67 | Q_PROPERTY( QString whatsThis READ whatsThis WRITE setWhatsThis )
|
|---|
| 68 | #ifndef QT_NO_ACCEL
|
|---|
| 69 | Q_PROPERTY( QKeySequence accel READ accel WRITE setAccel )
|
|---|
| 70 | #endif
|
|---|
| 71 | Q_PROPERTY( bool visible READ isVisible WRITE setVisible )
|
|---|
| 72 |
|
|---|
| 73 | public:
|
|---|
| 74 | QAction( QObject* parent, const char* name = 0 );
|
|---|
| 75 | #ifndef QT_NO_ACCEL
|
|---|
| 76 | QAction( const QString& menuText, QKeySequence accel,
|
|---|
| 77 | QObject* parent, const char* name = 0 );
|
|---|
| 78 | QAction( const QIconSet& icon, const QString& menuText, QKeySequence accel,
|
|---|
| 79 | QObject* parent, const char* name = 0 );
|
|---|
| 80 |
|
|---|
| 81 | QAction( const QString& text, const QIconSet& icon, const QString& menuText, QKeySequence accel,
|
|---|
| 82 | QObject* parent, const char* name = 0, bool toggle = FALSE ); // obsolete
|
|---|
| 83 | QAction( const QString& text, const QString& menuText, QKeySequence accel, QObject* parent,
|
|---|
| 84 | const char* name = 0, bool toggle = FALSE ); // obsolete
|
|---|
| 85 | #endif
|
|---|
| 86 | QAction( QObject* parent, const char* name , bool toggle ); // obsolete
|
|---|
| 87 | ~QAction();
|
|---|
| 88 |
|
|---|
| 89 | virtual void setIconSet( const QIconSet& );
|
|---|
| 90 | QIconSet iconSet() const;
|
|---|
| 91 | virtual void setText( const QString& );
|
|---|
| 92 | QString text() const;
|
|---|
| 93 | virtual void setMenuText( const QString& );
|
|---|
| 94 | QString menuText() const;
|
|---|
| 95 | virtual void setToolTip( const QString& );
|
|---|
| 96 | QString toolTip() const;
|
|---|
| 97 | virtual void setStatusTip( const QString& );
|
|---|
| 98 | QString statusTip() const;
|
|---|
| 99 | virtual void setWhatsThis( const QString& );
|
|---|
| 100 | QString whatsThis() const;
|
|---|
| 101 | #ifndef QT_NO_ACCEL
|
|---|
| 102 | virtual void setAccel( const QKeySequence& key );
|
|---|
| 103 | QKeySequence accel() const;
|
|---|
| 104 | #endif
|
|---|
| 105 | virtual void setToggleAction( bool );
|
|---|
| 106 |
|
|---|
| 107 | bool isToggleAction() const;
|
|---|
| 108 | bool isOn() const;
|
|---|
| 109 | bool isEnabled() const;
|
|---|
| 110 | bool isVisible() const;
|
|---|
| 111 | virtual bool addTo( QWidget* );
|
|---|
| 112 | virtual bool removeFrom( QWidget* );
|
|---|
| 113 |
|
|---|
| 114 | protected:
|
|---|
| 115 | virtual void addedTo( QWidget *actionWidget, QWidget *container );
|
|---|
| 116 | virtual void addedTo( int index, QPopupMenu *menu );
|
|---|
| 117 |
|
|---|
| 118 | public slots:
|
|---|
| 119 | void activate();
|
|---|
| 120 | void toggle();
|
|---|
| 121 | virtual void setOn( bool );
|
|---|
| 122 | virtual void setEnabled( bool );
|
|---|
| 123 | void setDisabled( bool );
|
|---|
| 124 | void setVisible( bool );
|
|---|
| 125 |
|
|---|
| 126 | signals:
|
|---|
| 127 | void activated();
|
|---|
| 128 | void toggled( bool );
|
|---|
| 129 |
|
|---|
| 130 | private slots:
|
|---|
| 131 | void internalActivation();
|
|---|
| 132 | void toolButtonToggled( bool );
|
|---|
| 133 | void objectDestroyed();
|
|---|
| 134 | void menuStatusText( int id );
|
|---|
| 135 | void showStatusText( const QString& );
|
|---|
| 136 | void clearStatusText();
|
|---|
| 137 |
|
|---|
| 138 | private:
|
|---|
| 139 | void init();
|
|---|
| 140 |
|
|---|
| 141 | friend class QActionGroup;
|
|---|
| 142 | friend class QActionGroupPrivate;
|
|---|
| 143 | QActionPrivate* d;
|
|---|
| 144 |
|
|---|
| 145 | #if defined(Q_DISABLE_COPY) // Disabled copy constructor and operator=
|
|---|
| 146 | QAction( const QAction & );
|
|---|
| 147 | QAction &operator=( const QAction & );
|
|---|
| 148 | #endif
|
|---|
| 149 | };
|
|---|
| 150 |
|
|---|
| 151 | class Q_EXPORT QActionGroup : public QAction
|
|---|
| 152 | {
|
|---|
| 153 | Q_OBJECT
|
|---|
| 154 | Q_PROPERTY( bool exclusive READ isExclusive WRITE setExclusive )
|
|---|
| 155 | Q_PROPERTY( bool usesDropDown READ usesDropDown WRITE setUsesDropDown )
|
|---|
| 156 |
|
|---|
| 157 | public:
|
|---|
| 158 | QActionGroup( QObject* parent, const char* name = 0 );
|
|---|
| 159 | QActionGroup( QObject* parent, const char* name , bool exclusive ); // obsolete
|
|---|
| 160 | ~QActionGroup();
|
|---|
| 161 | void setExclusive( bool );
|
|---|
| 162 | bool isExclusive() const;
|
|---|
| 163 | void add( QAction* a);
|
|---|
| 164 | void addSeparator();
|
|---|
| 165 | bool addTo( QWidget* );
|
|---|
| 166 | bool removeFrom( QWidget* );
|
|---|
| 167 | void setEnabled( bool );
|
|---|
| 168 | void setToggleAction( bool toggle );
|
|---|
| 169 | void setOn( bool on );
|
|---|
| 170 |
|
|---|
| 171 | void setUsesDropDown( bool enable );
|
|---|
| 172 | bool usesDropDown() const;
|
|---|
| 173 |
|
|---|
| 174 | void setIconSet( const QIconSet& );
|
|---|
| 175 | void setText( const QString& );
|
|---|
| 176 | void setMenuText( const QString& );
|
|---|
| 177 | void setToolTip( const QString& );
|
|---|
| 178 | void setWhatsThis( const QString& );
|
|---|
| 179 |
|
|---|
| 180 | protected:
|
|---|
| 181 | void childEvent( QChildEvent* );
|
|---|
| 182 | virtual void addedTo( QWidget *actionWidget, QWidget *container, QAction *a );
|
|---|
| 183 | virtual void addedTo( int index, QPopupMenu *menu, QAction *a );
|
|---|
| 184 | virtual void addedTo( QWidget *actionWidget, QWidget *container );
|
|---|
| 185 | virtual void addedTo( int index, QPopupMenu *menu );
|
|---|
| 186 |
|
|---|
| 187 | signals:
|
|---|
| 188 | void selected( QAction* );
|
|---|
| 189 |
|
|---|
| 190 | private slots:
|
|---|
| 191 | void childToggled( bool );
|
|---|
| 192 | void childDestroyed();
|
|---|
| 193 | void internalComboBoxActivated( int );
|
|---|
| 194 | void internalComboBoxHighlighted( int );
|
|---|
| 195 | void internalToggle( QAction* );
|
|---|
| 196 | void objectDestroyed();
|
|---|
| 197 |
|
|---|
| 198 | private:
|
|---|
| 199 | QActionGroupPrivate* d;
|
|---|
| 200 |
|
|---|
| 201 | #ifndef QT_NO_COMPAT
|
|---|
| 202 | public:
|
|---|
| 203 | void insert( QAction* a ) { add( a ); }
|
|---|
| 204 | #endif
|
|---|
| 205 |
|
|---|
| 206 | private:
|
|---|
| 207 | #if defined(Q_DISABLE_COPY) // Disabled copy constructor and operator=
|
|---|
| 208 | QActionGroup( const QActionGroup & );
|
|---|
| 209 | QActionGroup &operator=( const QActionGroup & );
|
|---|
| 210 | #endif
|
|---|
| 211 | };
|
|---|
| 212 |
|
|---|
| 213 | #endif
|
|---|
| 214 |
|
|---|
| 215 | #endif
|
|---|