1/* This file is part of the KDE project
2 Copyright (C) 2002 Matthias Hölzer-Klüpfel <mhk@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
21#ifndef K_ACCELERATORMANAGER_H
22#define K_ACCELERATORMANAGER_H
23
24#include <kdeui_export.h>
25
26class QWidget;
27class QString;
28
29/**
30 * KDE Accelerator manager.
31 *
32 * This class can be used to find a valid and working set of
33 * accelerators for any widget.
34 *
35 * @author Matthias Hölzer-Klüpfel <mhk@kde.org>
36*/
37
38class KDEUI_EXPORT KAcceleratorManager
39{
40public:
41
42 /**
43 * Manages the accelerators of a widget.
44 *
45 * Call this function on the top widget of the hierarchy you
46 * want to manage. It will fix the accelerators of the child widgets so
47 * there are never duplicate accelerators. It also tries to put
48 * accelerators on as many widgets as possible.
49 *
50 * The algorithm used tries to take the existing accelerators into
51 * account, as well as the class of each widget. Hopefully, the result
52 * is close to what you would assign manually.
53 *
54 * QPopupMenu's are managed dynamically, so when you add or remove entries,
55 * the accelerators are reassigned. If you add or remove widgets to your
56 * toplevel widget, you will have to call manage again to fix the
57 * accelerators.
58 *
59 * @param widget The toplevel widget you want to manage.
60 * @param programmers_mode if true, KAcceleratorManager adds (&) for removed
61 * accels and & before added accels
62 */
63
64 static void manage(QWidget *widget, bool programmers_mode = false );
65
66 /** \internal returns the result of the last manage operation. */
67 static void last_manage(QString &added, QString &changed, QString &removed);
68
69 /**
70 * Use this method for a widget (and its children) you want no accels to be set on.
71 */
72 static void setNoAccel( QWidget *widget );
73};
74
75
76#endif // K_ACCELERATORMANAGER_H
77