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 
00154  protected:
00155     ActionType m_type;
00156     bool m_bAllowLetterShortcuts;
00157     bool m_bAllowWinKey;
00158     // When set, pressing the 'Default' button will select the aDefaultKeycode4,
00159     //  otherwise aDefaultKeycode.
00160     bool m_bPreferFourModifierKeys;
00161 
00162     QRadioButton* m_prbNone;
00163     QRadioButton* m_prbDef;
00164     QRadioButton* m_prbCustom;
00165 
00166 
00167 #ifndef KDE_NO_COMPAT
00168  public:
00172     KKeyChooser( KAccel* actions, QWidget* parent,
00173             bool bCheckAgainstStdKeys,
00174             bool bAllowLetterShortcuts,
00175             bool bAllowWinKey = false );
00179     KKeyChooser( KGlobalAccel* actions, QWidget* parent,
00180             bool bCheckAgainstStdKeys,
00181             bool bAllowLetterShortcuts,
00182             bool bAllowWinKey = false );
00183 
00184  public slots:
00189     void listSync();
00190 
00191 #endif
00192  protected:
00193     virtual void virtual_hook( int id, void* data );
00194  private:
00195     class KKeyChooserPrivate *d;
00196     friend class KKeyDialog;
00197 };
00198 typedef KKeyChooser KKeyChooser;
00199 
00216 class KKeyDialog : public KDialogBase
00217 {
00218     Q_OBJECT
00219 
00220 public:
00226     KKeyDialog( bool bAllowLetterShortcuts = true, QWidget* parent = 0, const char* name = 0 );
00227 
00231     virtual ~KKeyDialog();
00232 
00241     bool insert( KActionCollection* ); // #### KDE4: remove me
00242 
00255         bool insert(KActionCollection *, const QString &title);
00256 
00257     bool configure( bool bSaveSettings = true );
00258 
00264     void commitChanges();
00265 
00273     static int configure( KActionCollection* coll, QWidget* parent = 0, bool bSaveSettings = true );
00274 
00280     static int configure( KAccel* keys, QWidget* parent = 0, bool bSaveSettings = true );
00281 
00286     static int configure( KGlobalAccel* keys, QWidget* parent = 0, bool bSaveSettings = true );
00287 
00288 
00295     static int configure( KActionCollection* coll, bool bAllowLetterShortcuts, QWidget* parent = 0, bool bSaveSettings = true ); // BCI: merge with bAllowLetterShortcuts = true
00296 
00301     static int configure( KAccel* keys, bool bAllowLetterShortcuts, QWidget* parent = 0, bool bSaveSettings = true ); // BCI: merge with bAllowLetterShortcuts = true
00302 
00307     static int configure( KGlobalAccel* keys, bool bAllowLetterShortcuts, QWidget* parent = 0, bool bSaveSettings = true ); // BCI: merge with bAllowLetterShortcuts = true
00308 
00313     static int configureKeys( KAccel* keys, bool save_settings = true, QWidget* parent = 0 )
00314         { return configure( keys, parent, save_settings ); }
00319     static int configureKeys( KGlobalAccel* keys, bool save_settings = true, QWidget* parent = 0 )
00320         { return configure( keys, parent, save_settings ); }
00325     static int configureKeys( KActionCollection* coll, const QString& /*xmlfile*/,
00326         bool save_settings = true, QWidget* parent = 0 )
00327         { return configure( coll, parent, save_settings ); }
00328 
00329 private:
00330     KKeyDialog( KKeyChooser::ActionType, bool bAllowLetterShortcuts = true, QWidget* parent = 0, const char* name = 0 );
00331 
00332  protected:
00333     virtual void virtual_hook( int id, void* data );
00334 
00335  private:
00336     class KKeyDialogPrivate* d;
00337     KKeyChooser* m_pKeyChooser;
00338 };
00339 
00340 #endif // __KKEYDIALOG_H__
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.0.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Oct 8 12:21:00 2003 by doxygen 1.2.18 written by Dimitri van Heesch, © 1997-2001