00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifndef __kactionclasses_h__
00028 #define __kactionclasses_h__
00029
00030 #include <kaction.h>
00031
00032 #include <qkeysequence.h>
00033 #include <qobject.h>
00034 #include <qvaluelist.h>
00035 #include <qguardedptr.h>
00036 #include <kguiitem.h>
00037 #include <kshortcut.h>
00038 #include <kstdaction.h>
00039 #include <kicontheme.h>
00040
00041 class QMenuBar;
00042 class QPopupMenu;
00043 class QComboBox;
00044 class QPoint;
00045 class QIconSet;
00046 class QString;
00047 class KToolBar;
00048
00049 class KAccel;
00050 class KAccelActions;
00051 class KConfig;
00052 class KConfigBase;
00053 class KURL;
00054 class KInstance;
00055 class KToolBar;
00056 class KActionCollection;
00057 class KPopupMenu;
00058 class KMainWindow;
00059
00068 class KDEUI_EXPORT KToggleAction : public KAction
00069 {
00070 Q_OBJECT
00071 Q_PROPERTY( bool checked READ isChecked WRITE setChecked )
00072 Q_PROPERTY( QString exclusiveGroup READ exclusiveGroup WRITE setExclusiveGroup )
00073 public:
00074
00085 KToggleAction( const QString& text, const KShortcut& cut = KShortcut(), QObject* parent = 0, const char* name = 0 );
00086
00095 KToggleAction( const QString& text, const KShortcut& cut,
00096 const QObject* receiver, const char* slot, QObject* parent, const char* name = 0 );
00097
00105 KToggleAction( const QString& text, const QIconSet& pix, const KShortcut& cut = KShortcut(),
00106 QObject* parent = 0, const char* name = 0 );
00107
00115 KToggleAction( const QString& text, const QString& pix, const KShortcut& cut = KShortcut(),
00116 QObject* parent = 0, const char* name = 0 );
00117
00127 KToggleAction( const QString& text, const QIconSet& pix, const KShortcut& cut,
00128 const QObject* receiver, const char* slot, QObject* parent, const char* name = 0 );
00129
00139 KToggleAction( const QString& text, const QString& pix, const KShortcut& cut,
00140 const QObject* receiver, const char* slot,
00141 QObject* parent, const char* name = 0 );
00142
00147 KToggleAction( QObject* parent = 0, const char* name = 0 );
00148
00152 virtual ~KToggleAction();
00153
00165 virtual int plug( QWidget* widget, int index = -1 );
00166
00170 bool isChecked() const;
00171
00176 QString exclusiveGroup() const;
00177
00184 virtual void setExclusiveGroup( const QString& name );
00185
00197 void setCheckedState( const KGuiItem& checkedItem );
00198
00200 virtual QString toolTip() const;
00201
00202 public slots:
00206 virtual void setChecked( bool );
00207
00208 protected slots:
00209 virtual void slotActivated();
00210
00211 protected:
00212 virtual void updateChecked( int id );
00213
00214 signals:
00215 void toggled( bool );
00216
00217 protected:
00218 virtual void virtual_hook( int id, void* data );
00219 private:
00220 class KToggleActionPrivate;
00221 KToggleActionPrivate *d;
00222 };
00223
00230 class KDEUI_EXPORT KRadioAction : public KToggleAction
00231 {
00232 Q_OBJECT
00233 public:
00244 KRadioAction( const QString& text, const KShortcut& cut = KShortcut(), QObject* parent = 0, const char* name = 0 );
00245
00254 KRadioAction( const QString& text, const KShortcut& cut,
00255 const QObject* receiver, const char* slot, QObject* parent, const char* name = 0 );
00256
00264 KRadioAction( const QString& text, const QIconSet& pix, const KShortcut& cut = KShortcut(),
00265 QObject* parent = 0, const char* name = 0 );
00266
00274 KRadioAction( const QString& text, const QString& pix, const KShortcut& cut = KShortcut(),
00275 QObject* parent = 0, const char* name = 0 );
00276
00286 KRadioAction( const QString& text, const QIconSet& pix, const KShortcut& cut,
00287 const QObject* receiver, const char* slot, QObject* parent, const char* name = 0 );
00288
00298 KRadioAction( const QString& text, const QString& pix, const KShortcut& cut,
00299 const QObject* receiver, const char* slot,
00300 QObject* parent, const char* name = 0 );
00301
00306 KRadioAction( QObject* parent = 0, const char* name = 0 );
00307
00308 protected:
00309 virtual void slotActivated();
00310
00311 protected:
00312 virtual void virtual_hook( int id, void* data );
00313 private:
00314 class KRadioActionPrivate;
00315 KRadioActionPrivate *d;
00316 };
00317
00329 class KDEUI_EXPORT KSelectAction : public KAction
00330 {
00331 Q_OBJECT
00332 Q_PROPERTY( int currentItem READ currentItem WRITE setCurrentItem )
00333 Q_PROPERTY( QStringList items READ items WRITE setItems )
00334 Q_PROPERTY( bool editable READ isEditable WRITE setEditable )
00335 Q_PROPERTY( int comboWidth READ comboWidth WRITE setComboWidth )
00336 Q_PROPERTY( QString currentText READ currentText )
00337 Q_PROPERTY( bool menuAccelsEnabled READ menuAccelsEnabled WRITE setMenuAccelsEnabled )
00338 public:
00339
00350 KSelectAction( const QString& text, const KShortcut& cut = KShortcut(), QObject* parent = 0, const char* name = 0 );
00351
00360 KSelectAction( const QString& text, const KShortcut& cut,
00361 const QObject* receiver, const char* slot, QObject* parent, const char* name = 0 );
00362
00370 KSelectAction( const QString& text, const QIconSet& pix, const KShortcut& cut = KShortcut(),
00371 QObject* parent = 0, const char* name = 0 );
00372
00380 KSelectAction( const QString& text, const QString& pix, const KShortcut& cut = KShortcut(),
00381 QObject* parent = 0, const char* name = 0 );
00382
00392 KSelectAction( const QString& text, const QIconSet& pix, const KShortcut& cut,
00393 const QObject* receiver, const char* slot, QObject* parent, const char* name = 0 );
00394
00404 KSelectAction( const QString& text, const QString& pix, const KShortcut& cut,
00405 const QObject* receiver, const char* slot,
00406 QObject* parent, const char* name = 0 );
00407
00412 KSelectAction( QObject* parent = 0, const char* name = 0 );
00413
00417 virtual ~KSelectAction();
00418
00430 virtual int plug( QWidget* widget, int index = -1 );
00431
00436 virtual bool isEditable() const;
00437
00442 virtual QStringList items() const;
00443
00447 virtual void changeItem( int index, const QString& text );
00448
00452 virtual QString currentText() const;
00453
00458 virtual int currentItem() const;
00459
00464 virtual int comboWidth() const;
00465
00472 void setMaxComboViewCount( int n );
00473
00477 QPopupMenu* popupMenu() const;
00478
00483 void setRemoveAmpersandsInCombo( bool b ) KDE_DEPRECATED;
00485 bool removeAmpersandsInCombo() const;
00486
00493 void setMenuAccelsEnabled( bool b );
00495 bool menuAccelsEnabled() const;
00496
00497 virtual bool isShortcutConfigurable() const { return false; }
00498
00499 public slots:
00505 virtual void setCurrentItem( int index );
00506
00511 virtual void setItems( const QStringList &lst );
00512
00516 virtual void clear();
00517
00522 virtual void setEditable( bool );
00523
00529 virtual void setComboWidth( int width );
00530
00531 protected:
00532 virtual void changeItem( int id, int index, const QString& text );
00533
00540 QStringList comboItems() const;
00541
00542 protected slots:
00543 virtual void slotActivated( int id );
00544 virtual void slotActivated( const QString &text );
00545 virtual void slotActivated();
00546
00547 signals:
00552 void activated( int index );
00557 void activated( const QString& text );
00558
00559 protected:
00560 virtual void updateCurrentItem( int id );
00561
00562 virtual void updateComboWidth( int id );
00563
00564 virtual void updateItems( int id );
00565
00566 virtual void updateClear( int id );
00567
00568 protected:
00569 virtual void virtual_hook( int id, void* data );
00570 private:
00571 void setupMenu() const;
00572 class KSelectActionPrivate;
00573 KSelectActionPrivate *d;
00574
00575 };
00576
00578
00581 class KDEUI_EXPORT_DEPRECATED KListAction : public KSelectAction
00582 {
00583 Q_OBJECT
00584 public:
00595 KListAction( const QString& text, const KShortcut& cut = KShortcut(), QObject* parent = 0,
00596 const char* name = 0 );
00597
00606 KListAction( const QString& text, const KShortcut& cut, const QObject* receiver,
00607 const char* slot, QObject* parent, const char* name = 0 );
00608
00616 KListAction( const QString& text, const QIconSet& pix, const KShortcut& cut = KShortcut(),
00617 QObject* parent = 0, const char* name = 0 );
00618
00626 KListAction( const QString& text, const QString& pix, const KShortcut& cut = KShortcut(),
00627 QObject* parent = 0, const char* name = 0 );
00628
00638 KListAction( const QString& text, const QIconSet& pix, const KShortcut& cut,
00639 const QObject* receiver, const char* slot, QObject* parent,
00640 const char* name = 0 );
00641
00651 KListAction( const QString& text, const QString& pix, const KShortcut& cut,
00652 const QObject* receiver, const char* slot, QObject* parent,
00653 const char* name = 0 );
00654
00659 KListAction( QObject* parent = 0, const char* name = 0 );
00660
00664 virtual ~KListAction();
00665
00666
00667 virtual QString currentText() const;
00668 virtual int currentItem() const;
00669
00670
00671 public slots:
00677 virtual void setCurrentItem( int index );
00678
00679 protected:
00680 virtual void virtual_hook( int id, void* data );
00681 private:
00682 class KListActionPrivate;
00683 KListActionPrivate *d;
00684 };
00685
00696 class KDEUI_EXPORT KRecentFilesAction : public KListAction
00697 {
00698 Q_OBJECT
00699 Q_PROPERTY( uint maxItems READ maxItems WRITE setMaxItems )
00700 public:
00708 KRecentFilesAction( const QString& text, const KShortcut& cut,
00709 QObject* parent, const char* name = 0,
00710 uint maxItems = 10 );
00711
00722 KRecentFilesAction( const QString& text, const KShortcut& cut,
00723 const QObject* receiver, const char* slot,
00724 QObject* parent, const char* name = 0,
00725 uint maxItems = 10 );
00726
00735 KRecentFilesAction( const QString& text, const QIconSet& pix, const KShortcut& cut,
00736 QObject* parent, const char* name = 0,
00737 uint maxItems = 10 );
00738
00747 KRecentFilesAction( const QString& text, const QString& pix, const KShortcut& cut,
00748 QObject* parent, const char* name = 0,
00749 uint maxItems = 10 );
00750
00762 KRecentFilesAction( const QString& text, const QIconSet& pix, const KShortcut& cut,
00763 const QObject* receiver, const char* slot,
00764 QObject* parent, const char* name = 0,
00765 uint maxItems = 10 );
00766
00778 KRecentFilesAction( const QString& text, const QString& pix, const KShortcut& cut,
00779 const QObject* receiver, const char* slot,
00780 QObject* parent, const char* name = 0,
00781 uint maxItems = 10 );
00782
00788 KRecentFilesAction( QObject* parent = 0, const char* name = 0,
00789 uint maxItems = 10 );
00790
00794 virtual ~KRecentFilesAction();
00795
00796 virtual int plug( QWidget *widget, int index = -1 );
00797
00801 uint maxItems() const;
00802
00803
00804
00811 virtual QStringList items() const;
00812
00818 QStringList completeItems() const;
00819
00820 public slots:
00829 void setMaxItems( uint maxItems );
00830
00838 void loadEntries( KConfig* config, QString groupname=QString::null );
00839
00847 void saveEntries( KConfig* config, QString groupname=QString::null );
00848
00854 void addURL( const KURL& url );
00855
00863 void addURL( const KURL& url, const QString& name );
00864
00870 void removeURL( const KURL& url );
00871
00875 void clearURLList();
00876
00877 signals:
00878
00884 void urlSelected( const KURL& url );
00885
00886 protected slots:
00887 void itemSelected( const QString& string );
00888 void menuAboutToShow();
00889 void menuItemActivated( int id );
00890 void slotClicked();
00891 virtual void slotActivated(int);
00892 virtual void slotActivated(const QString& );
00893 virtual void slotActivated();
00894
00895 protected:
00896 virtual void virtual_hook( int id, void* data );
00897
00898 private:
00899 void init();
00900
00901 class KRecentFilesActionPrivate;
00902 KRecentFilesActionPrivate *d;
00903 };
00904
00905 class KDEUI_EXPORT KFontAction : public KSelectAction
00906 {
00907 Q_OBJECT
00908 Q_PROPERTY( QString font READ font WRITE setFont )
00909 public:
00910 KFontAction( const QString& text, const KShortcut& cut = KShortcut(), QObject* parent = 0,
00911 const char* name = 0 );
00912 KFontAction( const QString& text, const KShortcut& cut,
00913 const QObject* receiver, const char* slot, QObject* parent,
00914 const char* name = 0 );
00915 KFontAction( const QString& text, const QIconSet& pix, const KShortcut& cut = KShortcut(),
00916 QObject* parent = 0, const char* name = 0 );
00917 KFontAction( const QString& text, const QString& pix, const KShortcut& cut = KShortcut(),
00918 QObject* parent = 0, const char* name = 0 );
00919 KFontAction( const QString& text, const QIconSet& pix, const KShortcut& cut,
00920 const QObject* receiver, const char* slot, QObject* parent,
00921 const char* name = 0 );
00922 KFontAction( const QString& text, const QString& pix, const KShortcut& cut,
00923 const QObject* receiver, const char* slot, QObject* parent,
00924 const char* name = 0 );
00925
00926
00927
00928 #define KFONTACTION_HAS_CRITERIA_ARG
00929 KFontAction( uint fontListCriteria, const QString& text,
00930 const KShortcut& cut = KShortcut(), QObject* parent = 0,
00931 const char* name = 0 );
00932 KFontAction( uint fontListCriteria, const QString& text, const QString& pix,
00933 const KShortcut& cut = KShortcut(),
00934 QObject* parent = 0, const char* name = 0 );
00935
00936 KFontAction( QObject* parent = 0, const char* name = 0 );
00937 ~KFontAction();
00938
00939 QString font() const {
00940 return currentText();
00941 }
00942
00943 int plug( QWidget*widget, int index = -1 );
00944
00945 public slots:
00946 void setFont( const QString &family );
00947
00948 protected:
00949 virtual void virtual_hook( int id, void* data );
00950 private:
00951 class KFontActionPrivate;
00952 KFontActionPrivate *d;
00953 };
00954
00955 class KDEUI_EXPORT KFontSizeAction : public KSelectAction
00956 {
00957 Q_OBJECT
00958 Q_PROPERTY( int fontSize READ fontSize WRITE setFontSize )
00959 public:
00960 KFontSizeAction( const QString& text, const KShortcut& cut = KShortcut(), QObject* parent = 0,
00961 const char* name = 0 );
00962 KFontSizeAction( const QString& text, const KShortcut& cut, const QObject* receiver,
00963 const char* slot, QObject* parent, const char* name = 0 );
00964 KFontSizeAction( const QString& text, const QIconSet& pix, const KShortcut& cut = KShortcut(),
00965 QObject* parent = 0, const char* name = 0 );
00966 KFontSizeAction( const QString& text, const QString& pix, const KShortcut& cut = KShortcut(),
00967 QObject* parent = 0, const char* name = 0 );
00968 KFontSizeAction( const QString& text, const QIconSet& pix, const KShortcut& cut,
00969 const QObject* receiver, const char* slot,
00970 QObject* parent, const char* name = 0 );
00971 KFontSizeAction( const QString& text, const QString& pix, const KShortcut& cut,
00972 const QObject* receiver, const char* slot,
00973 QObject* parent, const char* name = 0 );
00974 KFontSizeAction( QObject* parent = 0, const char* name = 0 );
00975
00976 virtual ~KFontSizeAction();
00977
00978 virtual int fontSize() const;
00979
00980 public slots:
00981 virtual void setFontSize( int size );
00982
00983 protected slots:
00984 virtual void slotActivated( int );
00985 virtual void slotActivated( const QString& );
00986 virtual void slotActivated() { KAction::slotActivated(); }
00987
00988 signals:
00989 void fontSizeChanged( int );
00990
00991 private:
00992 void init();
00993
00994
00995 protected:
00996 virtual void virtual_hook( int id, void* data );
00997 private:
00998 class KFontSizeActionPrivate;
00999 KFontSizeActionPrivate *d;
01000 };
01001
01002
01013 class KDEUI_EXPORT KActionMenu : public KAction
01014 {
01015 Q_OBJECT
01016 Q_PROPERTY( bool delayed READ delayed WRITE setDelayed )
01017 Q_PROPERTY( bool stickyMenu READ stickyMenu WRITE setStickyMenu )
01018
01019 public:
01020 KActionMenu( const QString& text, QObject* parent = 0,
01021 const char* name = 0 );
01022 KActionMenu( const QString& text, const QIconSet& icon,
01023 QObject* parent = 0, const char* name = 0 );
01024 KActionMenu( const QString& text, const QString& icon,
01025 QObject* parent = 0, const char* name = 0 );
01026 KActionMenu( QObject* parent = 0, const char* name = 0 );
01027 virtual ~KActionMenu();
01028
01029 virtual void insert( KAction*, int index = -1 );
01030 virtual void remove( KAction* );
01031
01032 KPopupMenu* popupMenu() const;
01033 void popup( const QPoint& global );
01034
01039 bool delayed() const;
01053 void setDelayed(bool _delayed);
01054
01059 bool stickyMenu() const;
01068 void setStickyMenu(bool sticky);
01069
01070 virtual int plug( QWidget* widget, int index = -1 );
01071
01072 protected:
01073 virtual void virtual_hook( int id, void* data );
01074 private:
01075 class KActionMenuPrivate;
01076 KActionMenuPrivate *d;
01077 };
01078
01086 class KDEUI_EXPORT KToolBarPopupAction : public KAction
01087 {
01088 Q_OBJECT
01089 Q_PROPERTY( bool delayed READ delayed WRITE setDelayed )
01090 Q_PROPERTY( bool stickyMenu READ stickyMenu WRITE setStickyMenu )
01091
01092 public:
01093
01094
01105 KToolBarPopupAction( const QString& text, const QString& icon, const KShortcut& cut = KShortcut(),
01106 QObject* parent = 0, const char* name = 0 );
01107
01123 KToolBarPopupAction( const QString& text, const QString& icon, const KShortcut& cut,
01124 const QObject* receiver, const char* slot,
01125 QObject* parent = 0, const char* name = 0 );
01126
01142 KToolBarPopupAction( const KGuiItem& item, const KShortcut& cut,
01143 const QObject* receiver, const char* slot,
01144 KActionCollection* parent, const char* name );
01145
01146 virtual ~KToolBarPopupAction();
01147
01148 virtual int plug( QWidget *widget, int index = -1 );
01149
01155 KPopupMenu *popupMenu() const;
01156
01161 bool delayed() const;
01167 void setDelayed(bool delayed);
01172 bool stickyMenu() const;
01182 void setStickyMenu(bool sticky);
01183
01184 private:
01185 KPopupMenu *m_popup;
01186 bool m_delayed:1;
01187 bool m_stickyMenu:1;
01188 protected:
01189 virtual void virtual_hook( int id, void* data );
01190 private:
01191 class KToolBarPopupActionPrivate;
01192 KToolBarPopupActionPrivate *d;
01193 };
01194
01208 class KDEUI_EXPORT KToggleToolBarAction : public KToggleAction
01209 {
01210 Q_OBJECT
01211 public:
01218 KToggleToolBarAction( const char* toolBarName, const QString& text,
01219 KActionCollection* parent, const char* name );
01220 KToggleToolBarAction( KToolBar *toolBar, const QString &text,
01221 KActionCollection *parent, const char *name );
01222 virtual ~KToggleToolBarAction();
01223
01224 virtual int plug( QWidget * widget, int index = -1 );
01225
01226 KToolBar *toolBar() { return m_toolBar; }
01227
01228 public slots:
01229 virtual void setChecked( bool );
01230
01231 private:
01232 QCString m_toolBarName;
01233 QGuardedPtr<KToolBar> m_toolBar;
01234 protected:
01235 virtual void virtual_hook( int id, void* data );
01236 private:
01237 class KToggleToolBarActionPrivate;
01238 KToggleToolBarActionPrivate *d;
01239 };
01240
01254 class KDEUI_EXPORT KToggleFullScreenAction : public KToggleAction
01255 {
01256 Q_OBJECT
01257 public:
01267 KToggleFullScreenAction( const KShortcut &cut,
01268 const QObject* receiver, const char* slot,
01269 QObject* parent, QWidget* window,
01270 const char* name );
01271 virtual ~KToggleFullScreenAction();
01272
01276 void setWindow( QWidget* window );
01277 public slots:
01278 virtual void setChecked( bool );
01279 protected:
01283 virtual bool eventFilter( QObject* o, QEvent* e );
01284 private:
01285 QWidget* window;
01286 protected:
01287 virtual void virtual_hook( int id, void* data );
01288 private:
01289 class KToggleFullScreenActionPrivate;
01290 KToggleFullScreenActionPrivate *d;
01291 };
01292
01293
01298 class KDEUI_EXPORT KWidgetAction : public KAction
01299 {
01300 Q_OBJECT
01301 public:
01307 KWidgetAction( QWidget* widget, const QString& text,
01308 const KShortcut& cut,
01309 const QObject* receiver, const char* slot,
01310 KActionCollection* parent, const char* name );
01311 virtual ~KWidgetAction();
01312
01316 QWidget* widget() { return m_widget; }
01317
01318 void setAutoSized( bool );
01319
01324 virtual int plug( QWidget* widget, int index = -1 );
01329 virtual void unplug( QWidget *w );
01330 protected slots:
01331 void slotToolbarDestroyed();
01332 private:
01333 QGuardedPtr<QWidget> m_widget;
01334 bool m_autoSized;
01335 protected:
01336 virtual void virtual_hook( int id, void* data );
01337 private:
01338 class KWidgetActionPrivate;
01339 KWidgetActionPrivate *d;
01340 };
01341
01342 class KDEUI_EXPORT KActionSeparator : public KAction
01343 {
01344 Q_OBJECT
01345 public:
01346 KActionSeparator( QObject* parent = 0, const char* name = 0 );
01347 virtual ~KActionSeparator();
01348
01349 virtual int plug( QWidget *widget, int index = -1 );
01350
01351 protected:
01352 virtual void virtual_hook( int id, void* data );
01353 private:
01354 class KActionSeparatorPrivate;
01355 KActionSeparatorPrivate *d;
01356 };
01357
01368 class KDEUI_EXPORT KPasteTextAction: public KAction
01369 {
01370 Q_OBJECT
01371 public:
01387 KPasteTextAction( const QString& text, const QString& icon, const KShortcut& cut,
01388 const QObject* receiver, const char* slot,
01389 QObject* parent = 0, const char* name = 0 );
01390
01391 virtual ~KPasteTextAction();
01392
01403 void setMixedMode(bool mode);
01404
01405 virtual int plug( QWidget *widget, int index = -1 );
01406
01407 protected slots:
01408 void menuAboutToShow();
01409 void menuItemActivated( int id);
01410 virtual void slotActivated();
01411
01412 protected:
01413 virtual void virtual_hook( int id, void* data );
01414
01415 private:
01416 KPopupMenu *m_popup;
01417 bool m_mixedMode;
01418 class KPasteTextActionPrivate;
01419 KPasteTextActionPrivate *d;
01420 };
01421
01422 #endif