File indexing completed on 2023-09-24 08:11:03
0001 /* 0002 This file is part of the KDE libraries 0003 SPDX-FileCopyrightText: 1997 Matthias Kalle Dalheimer <kalle@kde.org> 0004 SPDX-FileCopyrightText: 1998, 1999, 2000 KDE Team 0005 SPDX-FileCopyrightText: 2008 Nick Shaforostoff <shaforostoff@kde.ru> 0006 0007 SPDX-License-Identifier: LGPL-2.0-or-later 0008 */ 0009 0010 #ifndef KCHECKACCELERATORS_H_ 0011 #define KCHECKACCELERATORS_H_ 0012 0013 #include <QObject> 0014 #include <QPointer> 0015 0016 #include <QTimer> 0017 0018 class QDialog; 0019 class QTextBrowser; 0020 0021 /** 0022 @internal 0023 This class allows translators (and application developers) to check for accelerator 0024 conflicts in menu and widgets. Put the following in your kdeglobals (or the config 0025 file for the application you're testing): 0026 0027 \code 0028 [Development] 0029 CheckAccelerators=F12 0030 AutoCheckAccelerators=false 0031 AlwaysShowCheckAccelerators=false 0032 \endcode 0033 0034 The checking can be either manual or automatic. To perform manual check, press 0035 the keyboard shortcut set to 'CheckAccelerators' (here F12). If automatic checking 0036 is enabled by setting 'AutoCheckAccelerators' to true, check will be performed every 0037 time the GUI changes. It's possible that in certain cases the check will be 0038 done also when no visible changes in the GUI happen or the check won't be done 0039 even if the GUI changed (in the latter case, use manual check ). Automatic 0040 checks can be anytime disabled by the checkbox in the dialog presenting 0041 the results of the check. If you set 'AlwaysShowCheckAccelerators' to true, 0042 the dialog will be shown even if the automatic check didn't find any conflicts, 0043 and all submenus will be shown, even those without conflicts. 0044 0045 The dialog first lists the name of the window, then all results for all menus 0046 (if the window has a menubar) and then result for all controls in the active 0047 window (if there are any checkboxes etc.). For every submenu and all controls 0048 there are shown all conflicts grouped by accelerator, and a list of all used 0049 accelerators. 0050 0051 COPY WIDGET TEXT: 0052 0053 You can copy widgets' texts to find them in translation files faster by middle-clicking them. 0054 Put the following lines in ~/.config/kdeglobals (or in rc file for specific app): 0055 0056 \code 0057 [Development] 0058 CopyWidgetText=true 0059 CopyWidgetTextCommand=find_in_po_script "%1" "%2" 0060 \endcode 0061 0062 Where %1 gets replaced with program name and %2 - with text. 0063 CopyWidgetTextCommand may be empty, in which case the text gets copied to clipboard. 0064 Press Ctrl+MMB to get widget text w/o accelerator mark (&) 0065 0066 */ 0067 0068 class KCheckAccelerators : public QObject 0069 { 0070 Q_OBJECT 0071 public: 0072 KCheckAccelerators(QObject *parent, int key, bool autoCheck, bool copyWidgetText); 0073 /** 0074 * Re-implemented to filter the parent's events. 0075 */ 0076 bool eventFilter(QObject *, QEvent *e) override; 0077 0078 private: 0079 void checkAccelerators(bool automatic); 0080 int key; 0081 bool block; 0082 bool alwaysShow; 0083 bool autoCheck; 0084 0085 bool copyWidgetText; 0086 QString copyWidgetTextCommand; 0087 0088 QTimer autoCheckTimer; 0089 void createDialog(QWidget *parent, bool automatic); 0090 QPointer<QDialog> drklash; 0091 QTextBrowser *drklash_view; 0092 0093 private Q_SLOTS: 0094 void autoCheckSlot(); 0095 void slotDisableCheck(bool); 0096 }; 0097 0098 #endif