kdeui Library API Documentation

kkeydialog.h

00001 /* This file is part of the KDE libraries
00002     Copyright (C) 1997 Nicolas Hadacek <hadacek@kde.org>
00003     Copyright (C) 2001,2001 Ellis Whitehead <ellis@kde.org>
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public License
00016     along with this library; see the file COPYING.LIB.  If not, write to
00017     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00018     Boston, MA 02111-1307, USA.
00019 */
00020 
00021 #ifndef __KKEYDIALOG_H__
00022 #define __KKEYDIALOG_H__
00023 
00024 #include <qdict.h>
00025 #include <kdialogbase.h>
00026 #include <klistview.h>
00027 
00028 class QButtonGroup;
00029 class QCheckBox;
00030 class QGroupBox;
00031 class QLabel;
00032 class QLineEdit;
00033 class QRadioButton;
00034 class KAccel;
00035 class KAccelActions;
00036 class KActionCollection;
00037 class KConfigBase;
00038 class KGlobalAccel;
00039 class KKeySequence;
00040 class KShortcut;
00041 class KShortcutList;
00042 class KKeyChooserItem;
00043 
00058 class KKeyChooser : public QWidget
00059 {
00060     Q_OBJECT
00061  public:
00062     enum ActionType { Application, ApplicationGlobal, Standard, Global };
00063 
00070     KKeyChooser( QWidget* parent, ActionType type = Application, bool bAllowLetterShortcuts = true );
00071     KKeyChooser( KActionCollection* coll, QWidget* parent, bool bAllowLetterShortcuts = true );
00072     KKeyChooser( KAccel* actions, QWidget* parent, bool bAllowLetterShortcuts = true );
00073     KKeyChooser( KGlobalAccel* actions, QWidget* parent );
00074     KKeyChooser( KShortcutList*, QWidget* parent, ActionType type = Application, bool bAllowLetterShortcuts = true );
00075 
00076     virtual ~KKeyChooser();
00077 
00082     bool insert( KActionCollection* ); // #### KDE4 : remove me
00089     bool insert( KActionCollection *, const QString &title);
00090 
00091     void syncToConfig( const QString& sConfigGroup, KConfigBase* pConfig, bool bClearUnset );
00092 
00097     void commitChanges();
00098 
00105     void save();
00106 
00107  signals:
00111     void keyChange();
00112 
00113  public slots:
00117     void allDefault();
00118 
00124     void setPreferFourModifierKeys( bool preferFourModifierKeys );
00125 
00126  // KDE4 a lot of stuff in this class should be probably private:
00127  protected:
00128     enum { NoKey = 1, DefaultKey, CustomKey };
00129 
00130     void initGUI( ActionType type, bool bAllowLetterShortcuts );
00131     bool insert( KAccel* );
00132     bool insert( KGlobalAccel* );
00133     bool insert( KShortcutList* );
00135     void buildListView( uint iList, const QString &title = QString::null );
00136 
00137     void readGlobalKeys();
00138 
00139     void updateButtons();
00140     void fontChange( const QFont& _font );
00141     void setShortcut( const KShortcut& cut );
00142     bool isKeyPresent( const KShortcut& cut, bool warnuser = true );
00143         bool isKeyPresentLocally( const KShortcut& cut, KKeyChooserItem* ignoreItem, const QString& warnText );
00144     void _warning( const KKeySequence& seq, QString sAction, QString sTitle );
00145 
00146  protected slots:
00147     void slotNoKey();
00148     void slotDefaultKey();
00149     void slotCustomKey();
00150     void slotListItemSelected( QListViewItem *item );
00151     void capturedShortcut( const KShortcut& cut );
00152         void slotSettingsChanged( int );
00153         void slotListItemDoubleClicked ( QListViewItem * ipoQListViewItem, const QPoint & ipoQPoint, int c );
00154 
00155  protected:
00156     ActionType m_type;
00157     bool m_bAllowLetterShortcuts;
00158     bool m_bAllowWinKey;
00159     // When set, pressing the 'Default' button will select the aDefaultKeycode4,
00160     //  otherwise aDefaultKeycode.
00161     bool m_bPreferFourModifierKeys;
00162 
00163     QRadioButton* m_prbNone;
00164     QRadioButton* m_prbDef;
00165     QRadioButton* m_prbCustom;
00166 
00167 
00168 #ifndef KDE_NO_COMPAT
00169  public:
00173     KKeyChooser( KAccel* actions, QWidget* parent,
00174             bool bCheckAgainstStdKeys,
00175             bool bAllowLetterShortcuts,
00176             bool bAllowWinKey = false );
00180     KKeyChooser( KGlobalAccel* actions, QWidget* parent,
00181             bool bCheckAgainstStdKeys,
00182             bool bAllowLetterShortcuts,
00183             bool bAllowWinKey = false );
00184 
00185  public slots:
00190     void listSync();
00191 
00192 #endif
00193  protected:
00194     virtual void virtual_hook( int id, void* data );
00195  private:
00196     class KKeyChooserPrivate *d;
00197     friend class KKeyDialog;
00198 };
00199 typedef KKeyChooser KKeyChooser;
00200 
00217 class KKeyDialog : public KDialogBase
00218 {
00219     Q_OBJECT
00220 
00221 public:
00227     KKeyDialog( bool bAllowLetterShortcuts = true, QWidget* parent = 0, const char* name = 0 );
00228 
00232     virtual ~KKeyDialog();
00233 
00242     bool insert( KActionCollection* ); // #### KDE4: remove me
00243 
00256         bool insert(KActionCollection *, const QString &title);
00257 
00258     bool configure( bool bSaveSettings = true );
00259 
00265     void commitChanges();
00266 
00274     static int configure( KActionCollection* coll, QWidget* parent = 0, bool bSaveSettings = true );
00275 
00281     static int configure( KAccel* keys, QWidget* parent = 0, bool bSaveSettings = true );
00282 
00287     static int configure( KGlobalAccel* keys, QWidget* parent = 0, bool bSaveSettings = true );
00288 
00289 
00296     static int configure( KActionCollection* coll, bool bAllowLetterShortcuts, QWidget* parent = 0, bool bSaveSettings = true ); // BCI: merge with bAllowLetterShortcuts = true
00297 
00302     static int configure( KAccel* keys, bool bAllowLetterShortcuts, QWidget* parent = 0, bool bSaveSettings = true ); // BCI: merge with bAllowLetterShortcuts = true
00303 
00308     static int configure( KGlobalAccel* keys, bool bAllowLetterShortcuts, QWidget* parent = 0, bool bSaveSettings = true ); // BCI: merge with bAllowLetterShortcuts = true
00309 
00314     static int configureKeys( KAccel* keys, bool save_settings = true, QWidget* parent = 0 )
00315         { return configure( keys, parent, save_settings ); }
00320     static int configureKeys( KGlobalAccel* keys, bool save_settings = true, QWidget* parent = 0 )
00321         { return configure( keys, parent, save_settings ); }
00326     static int configureKeys( KActionCollection* coll, const QString& /*xmlfile*/,
00327         bool save_settings = true, QWidget* parent = 0 )
00328         { return configure( coll, parent, save_settings ); }
00329 
00330 private:
00331     KKeyDialog( KKeyChooser::ActionType, bool bAllowLetterShortcuts = true, QWidget* parent = 0, const char* name = 0 );
00332 
00333  protected:
00334     virtual void virtual_hook( int id, void* data );
00335 
00336  private:
00337     class KKeyDialogPrivate* d;
00338     KKeyChooser* m_pKeyChooser;
00339 };
00340 
00341 #endif // __KKEYDIALOG_H__
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.4.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sun Feb 27 22:15:03 2005 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001