/***************************************************************************
 *   Copyright (C) 2003-2005 by liuspider                                  *
 *   liuspider@users.sourceforge.net                                       *
 *                                                                         *
 *   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 SKIMKEYGRABBER_H
#define SKIMKEYGRABBER_H

#include <kdialogbase.h>
// #include <kshortcut.h> 
class QCheckBox;

class SkimKeyGrabber : public KDialogBase
{
Q_OBJECT
public:
    SkimKeyGrabber(QWidget *parent = 0, const char *name = 0);
    QString getShortcut() {return finalKeys;};
//     virtual ~SkimKeyGrabber();
    
public slots:
    int exec();
protected:
    virtual void keyPressEvent ( QKeyEvent * e );
    virtual void keyReleaseEvent ( QKeyEvent * e );
private:
    void checkKeys(int key, QValueList<int> & oldkeys, QValueList<int> & newkeys, QCheckBox * cb);
    QValueList<int> keys;
    QString finalKeys;
    QCheckBox * ctrl;
    QCheckBox * alt;
    QCheckBox * shift;
    QCheckBox * release;
//     QCheckBox * leftRight;
};

class KLineEdit;

#include <qtoolbutton.h>

class SkimShortcutEditor : public QWidget
{
Q_OBJECT
public:
    SkimShortcutEditor(QWidget *parent = 0, const char *name = 0);
    KLineEdit * lineEditor;
private slots:
    void invokeGrabber();
private:
    QToolButton * button;
};

class KEditListBox;
class SkimShortcutListEditor : public KDialogBase
{
Q_OBJECT
public:
    SkimShortcutListEditor(QWidget *parent = 0, const char *name = 0);
    void setStringList(QStringList &);
    QString getCombinedString();
private slots:
    void verifyShortcut(const QString &);
private:
    SkimShortcutEditor* editor;
    KEditListBox* listBox;
};

class SkimEditShortcutButton : public QToolButton
{
Q_OBJECT
public:
    SkimEditShortcutButton(QWidget *parent = 0, const char *name = 0);
public slots:
    void setShortcuts(const QString &);
//     void setEditor(KLineEdit *k);
signals:
    void setEditorText(const QString &);
private slots:
    void invokeShortcutListEditor();
private:
    KLineEdit * lineEditor;
    QString shortcuts;
};

#endif
