1 /*
2     SPDX-FileCopyrightText: 2006-2008 Robert Knight <robertknight@gmail.com>
3     SPDX-FileCopyrightText: 1997, 1998 Lars Doelle <lars.doelle@on-line.de>
4 
5     SPDX-License-Identifier: GPL-2.0-or-later
6 */
7 
8 #ifndef COMPOSITEWIDGET_H
9 #define COMPOSITEWIDGET_H
10 
11 #include <QWidget>
12 
13 namespace Konsole
14 {
15 // Watches compositeWidget and all its focusable children,
16 // and emits focusChanged() signal when either compositeWidget's
17 // or a child's focus changed.
18 // Limitation: children added after the object was created
19 // will not be registered.
20 class CompositeWidgetFocusWatcher : public QObject
21 {
22     Q_OBJECT
23 
24 public:
25     explicit CompositeWidgetFocusWatcher(QWidget *compositeWidget);
26     bool eventFilter(QObject *watched, QEvent *event) Q_DECL_OVERRIDE;
27 
28 Q_SIGNALS:
29     void compositeFocusChanged(bool focused);
30 
31 private:
32     void registerWidgetAndChildren(QWidget *widget);
33 
34     QWidget *_compositeWidget;
35 };
36 
37 } // namespace Konsole
38 
39 #endif // COMPOSITEWIDGET_H
40