keydialog.h 2.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/***************************************************************************
                          keydialog.h  -  description
                             -------------------
    begin                : Tue Mar 11 19:00:00 CET 2003
    copyright            : (C) 2003 by Stefan Asserhall
    email                : stefan.asserhall@telia.com
***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   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.                                   *
 *                                                                         *
 ***************************************************************************/

18 19
#ifndef KEYDIALOG_H
#define KEYDIALOG_H
20

21
#include <kdeversion.h>
22
#include <kactioncollection.h>
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
#include <kdialogbase.h>
#include <kglobalaccel.h>
#include <kkeydialog.h>

#include <qhbuttongroup.h>
#include <qwidgetstack.h>

class KeyDialog : public KDialogBase
{
    Q_OBJECT

public:
    /**
     * Constructs a KeyDialog called @p name as a child of @p parent.
     */
38
    KeyDialog(KGlobalAccel *keys, KActionCollection *actionCollection, QWidget *parent = 0, const char* name = 0);
39 40 41 42 43 44 45 46 47 48 49

    /**
     * Destructor. Deletes all resources used by a KeyDialog object.
     */
    virtual ~KeyDialog();

    /**
     * This is a member function, provided to allow inserting both global
     * accelerators and actions. It behaves essentially like the functions
     * in KKeyDialog.
     */
50
    static int configure(KGlobalAccel *keys, KActionCollection *actionCollection, QWidget *parent = 0);
51 52 53 54 55 56

    /**
     * This is a member function, provided to create a global accelerator with
     * standard keys. It behaves like the function in KGlobalAccel.
     */
    static void insert(KGlobalAccel *keys, const QString& action, const QString& label,
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
		       const QObject *objSlot, const char *methodSlot);

private:

    /**
     * Groups of keys that can be selected in the dialog.
     */
    enum KeyGroup { NoKeys = 0, StandardKeys = 1, MultimediaKeys = 2 };

    struct KeyInfo {
	QString action;
	KShortcut shortcut[3][2];
    };
    
    void newDialog(KGlobalAccel *keys, KActionCollection *actionCollection, int selectedButton = 0);
    int configure();
73 74 75 76 77 78

private slots:
    void slotKeys(int group);
    void slotDefault();

private:
79
    KActionCollection *m_actionCollection;
80 81 82
    KGlobalAccel      *m_keys;
    KKeyChooser       *m_pKeyChooser;
    QHButtonGroup     *m_group;
83 84 85 86
    QWidgetStack      *m_widgetStack;

    static const KeyInfo keyInfo[];
    static const uint    keyInfoCount;
87 88
};

89
#endif // KEYDIALOG_H