1/*
2 This file is part of the KDE libraries
3 SPDX-FileCopyrightText: 1997 Matthias Kalle Dalheimer <kalle@kde.org>
4 SPDX-FileCopyrightText: 1998, 1999, 2000 KDE Team
5 SPDX-FileCopyrightText: 2008 Nick Shaforostoff <shaforostoff@kde.ru>
6
7 SPDX-License-Identifier: LGPL-2.0-or-later
8*/
9
10#ifndef KCHECKACCELERATORS_H_
11#define KCHECKACCELERATORS_H_
12
13#include <QObject>
14#include <QPointer>
15
16#include <QTimer>
17
18class QDialog;
19class QTextBrowser;
20
21/**
22 @internal
23 This class allows translators (and application developers) to check for accelerator
24 conflicts in menu and widgets. Put the following in your kdeglobals (or the config
25 file for the application you're testing):
26
27 \code
28 [Development]
29 CheckAccelerators=F12
30 AutoCheckAccelerators=false
31 AlwaysShowCheckAccelerators=false
32 \endcode
33
34 The checking can be either manual or automatic. To perform manual check, press
35 the keyboard shortcut set to 'CheckAccelerators' (here F12). If automatic checking
36 is enabled by setting 'AutoCheckAccelerators' to true, check will be performed every
37 time the GUI changes. It's possible that in certain cases the check will be
38 done also when no visible changes in the GUI happen or the check won't be done
39 even if the GUI changed (in the latter case, use manual check ). Automatic
40 checks can be anytime disabled by the checkbox in the dialog presenting
41 the results of the check. If you set 'AlwaysShowCheckAccelerators' to true,
42 the dialog will be shown even if the automatic check didn't find any conflicts,
43 and all submenus will be shown, even those without conflicts.
44
45 The dialog first lists the name of the window, then all results for all menus
46 (if the window has a menubar) and then result for all controls in the active
47 window (if there are any checkboxes etc.). For every submenu and all controls
48 there are shown all conflicts grouped by accelerator, and a list of all used
49 accelerators.
50*/
51
52class KCheckAccelerators : public QObject
53{
54 Q_OBJECT
55public:
56 KCheckAccelerators(QObject *parent, int key, bool autoCheck);
57 /**
58 * Re-implemented to filter the parent's events.
59 */
60 bool eventFilter(QObject *, QEvent *e) override;
61
62private:
63 void checkAccelerators(bool automatic);
64 int key;
65 bool block;
66 bool alwaysShow;
67 bool autoCheck;
68
69 QTimer autoCheckTimer;
70 void createDialog(QWidget *parent, bool automatic);
71 QPointer<QDialog> drklash;
72 QTextBrowser *drklash_view;
73
74private Q_SLOTS:
75 void autoCheckSlot();
76 void slotDisableCheck(bool);
77};
78
79#endif
80

source code of kxmlgui/src/kcheckaccelerators.h