File indexing completed on 2024-04-28 03:58:58

0001 /*
0002     This file is part of the KDE project
0003     SPDX-FileCopyrightText: 2002 Matthias Hölzer-Klüpfel <mhk@kde.org>
0004 
0005     SPDX-License-Identifier: LGPL-2.0-or-later
0006 */
0007 
0008 #ifndef K_ACCELERATORMANAGER_H
0009 #define K_ACCELERATORMANAGER_H
0010 
0011 #include <kwidgetsaddons_export.h>
0012 
0013 #include <QStringList>
0014 
0015 class QWidget;
0016 class QString;
0017 
0018 /**
0019  * @class KAcceleratorManager kacceleratormanager.h KAcceleratorManager
0020  *
0021  * KDE Accelerator manager.
0022  *
0023  * This class can be used to find a valid and working set of
0024  * accelerators for any widget.
0025  *
0026  * @author Matthias Hölzer-Klüpfel <mhk@kde.org>
0027  */
0028 class KWIDGETSADDONS_EXPORT KAcceleratorManager
0029 {
0030 public:
0031     /**
0032      * Manages the accelerators of a widget.
0033      *
0034      * Call this function on the top widget of the hierarchy you
0035      * want to manage. It will fix the accelerators of the child widgets so
0036      * there are never duplicate accelerators. It also tries to put
0037      * accelerators on as many widgets as possible.
0038      *
0039      * The algorithm used tries to take the existing accelerators into
0040      * account, as well as the class of each widget. Hopefully, the result
0041      * is close to what you would assign manually.
0042      *
0043      * QMenu's are managed dynamically, so when you add or remove entries,
0044      * the accelerators are reassigned. If you add or remove widgets to your
0045      * toplevel widget, you will have to call manage again to fix the
0046      * accelerators.
0047      *
0048      * @param widget The toplevel widget you want to manage.
0049      * @param programmers_mode if true, KAcceleratorManager adds (&) for removed
0050      *             accels and & before added accels
0051      */
0052 
0053     static void manage(QWidget *widget, bool programmers_mode = false);
0054 
0055     /** \internal returns the result of the last manage operation. */
0056     static void last_manage(QString &added, QString &changed, QString &removed);
0057 
0058     /**
0059      * Use this method for a widget (and its children) you want no accels to be set on.
0060      */
0061     static void setNoAccel(QWidget *widget);
0062 
0063     /**
0064      * Append names to a list of standard action names.
0065      * These strings will be given higher priority when assigning keyboard accelerators.
0066      * @since 5.0
0067      */
0068     static void addStandardActionNames(const QStringList &names);
0069 };
0070 
0071 #endif // K_ACCELERATORMANAGER_H