/***************************************************************************
                          kkeyled.h  -  description
                             -------------------
    begin                : Mon Apr 23 13:06:31 CEST 2001
    copyright            : (C) 2001 by Dieter Landolt
    email                : dieter.landolt@secs.ch
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#ifndef KKEYLED_H
#define KKEYLED_H

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <kapplication.h>
#include <kmainwindow.h>
#include <qwidget.h>

extern "C" {
#include <X11/Xlib.h>
#include <X11/XKBlib.h>
}

class DockWidget;        
class QCheckBox;
/** Kkeyled is the base class of the porject */

class Kkeyled : public KMainWindow
{
  Q_OBJECT 
public:
    /** construtor */
    Kkeyled(QWidget* parent=0, const char *name="KKeyLed",Qt::WFlags f=0);
    /** destructor */
    ~Kkeyled();
    void show();
private:
  /** Timer for to asc keyboardstate */
  QTimer* blink;
  /** Dockwidget for numlockevents */
  DockWidget *nl;
  /** Dockwidget for Capslock */
  DockWidget *cl;
  /** Dockwidget for Scrolllock */
  DockWidget *sl;
  /** CheckBox for Numlock */
  QCheckBox *cbnl;
  /** CheckBox for Capslock */
  QCheckBox *cbcl;
  /** CheckBox for Scrollock */
  QCheckBox *cbsl;
  /** QCheckBox witch save's if the saved Ledstat is to restore at starttime or not */
  QCheckBox *restLedstate;
public: // Public attributes
  /**
   * Status of the light is on/off.
   * @short LED on/off.
   */
  enum State { Off, On };

protected slots: // Protected slots
  /** Handels the Timer event and modifies
the Keyboardstate and after sends the signal to 
the right Object 
 */
  virtual void checkState();
  /** Saving the state of the Le'ds to Config file Configfile */
  void configSaveState();
  /** overwrihgt the show event for repositioning the window on top
of the icon */
  void showEvent(QShowEvent *e);
  /** Saving the Configfile */
  void configSave(int);
  /** Starts and handles the detailconfig dialog */
  void detailconfig();
signals: // Signals
  /** Sends a Signal if the Numlockkey is changed */
  void numLockKeyChanged(State);
  /** sends this signal if the scrolllock key ist changed */
  void scrollLockKeyChanged(State);
  /** Sends this signal if the Capslock Key is Changed */
  void capsLockKeyChanged(State);
public slots: // Public slots
  /** sets the Capslockkey to a spezified value */
  virtual void setCapsLockState(bool st);
  /** sets the Numlockkey to a spezified value */
  virtual void setNumLockState(bool st);
  /** sets the Scrollockkey to a spezified value */
  virtual void setScrollLockState(bool st);

private: // Private methods
  /** Initialize the xkeyboard */
  int xkb_init();
  /** Modifie the Keyboardmask */
  unsigned int xkb_mask_modifier( XkbDescPtr xkb, const char *name );
  /** generallfunction to return the mask for the modifier key */
  unsigned int xkb_lock_mask(char* keyname);   
  /** set the keystate */
  void setLockState(bool st, unsigned int &mask);
protected:
    /*!
        \Kkeyled::focusOutEvent( QFocusEvent * )
     */
    void focusOutEvent( QFocusEvent * );

};

#endif


syntax highlighted by Code2HTML, v. 0.9.1