home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kkeybutton.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  2.6 KB  |  92 lines

  1. /* This file is part of the KDE libraries
  2.     Copyright (C) 2001, 2002 Ellis Whitehead <ellis@kde.org>
  3.  
  4.     This library is free software; you can redistribute it and/or
  5.     modify it under the terms of the GNU Library General Public
  6.     License as published by the Free Software Foundation; either
  7.     version 2 of the License, or (at your option) any later version.
  8.  
  9.     This library is distributed in the hope that it will be useful,
  10.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12.     Library General Public License for more details.
  13.  
  14.     You should have received a copy of the GNU Library General Public License
  15.     along with this library; see the file COPYING.LIB.  If not, write to
  16.     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  17.     Boston, MA 02110-1301, USA.
  18. */
  19.  
  20. #ifndef _KKEYBUTTON_H_
  21. #define _KKEYBUTTON_H_
  22.  
  23. #include <qpushbutton.h>
  24. #include <kshortcut.h>
  25.  
  26. /**
  27.  * @short A push button that looks like a keyboard key.
  28.  *
  29.  * You must call setShortcut() to set the widget's currently displayed key.
  30.  * You can call captureShortcut() to get a new shortcut from the user.
  31.  * If captureShortcut() succeeds, then the capturedShortcut() signal will be
  32.  * emitted with the value of the new shortcut.  The widget containing
  33.  * a KKeyButton widget must connect to this signal and check if the shortcut
  34.  * is valid.  If it is, you will need to call setShortcut() with the new
  35.  * value in order make it the key currently displayed.
  36.  *
  37.  * @author Mark Donohoe <donohoe@kde.org>
  38.  * @internal
  39.  */
  40. class KDEUI_EXPORT KKeyButton: public QPushButton
  41. {
  42.     Q_OBJECT
  43.  
  44.  public:
  45.     /**
  46.     * Constructs  key button widget.
  47.     */
  48.     KKeyButton( QWidget *parent = 0, const char *name = 0 );
  49.     /**
  50.     * Destructs the key button widget.
  51.     */
  52.     virtual ~KKeyButton();
  53.  
  54.     /** @deprecated Use setShortcut( cut, false ) instead */
  55.     void setShortcut( const KShortcut& cut ) KDE_DEPRECATED;
  56.     /// @since 3.1
  57.     void setShortcut( const KShortcut& cut, bool bQtShortcut );
  58.     const KShortcut& shortcut() const
  59.         { return m_cut; }
  60.  
  61.     /**
  62.     * Reimplemented for internal purposes.
  63.     */
  64.     void setText( const QString& text );
  65.  
  66.  signals:
  67.     void capturedShortcut( const KShortcut& );
  68.  
  69.  public slots:
  70.     /**
  71.      * Call this method to capture a shortcut from the keyboard.
  72.      * If it succeeds, the capturedShortcut() signal will be emitted.
  73.      */
  74.     void captureShortcut();
  75.  
  76.  protected:
  77.     KShortcut m_cut;
  78.     bool m_bEditing;
  79.  
  80.     /**
  81.     * Reimplemented for internal reasons.
  82.     */
  83.     void drawButton( QPainter* _painter );
  84.  
  85.  protected:
  86.     virtual void virtual_hook( int id, void* data );
  87.  private:
  88.     class KKeyButtonPrivate* d;
  89. };
  90.  
  91. #endif
  92.