ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
ecvShortcutDecorator.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #ifndef ecvShortcutDecorator_h
9 #define ecvShortcutDecorator_h
10 
11 // Local
12 #include "CV_db.h"
13 
14 // Qt
15 #include <QColor>
16 #include <QFrame>
17 #include <QList>
18 #include <QObject>
19 #include <QPointer>
20 
21 class ecvModalShortcut;
22 
41 class CV_DB_LIB_API ecvShortcutDecorator : public QObject {
42  Q_OBJECT
43 
44 public:
45  using Superclass = QObject;
46 
52  explicit ecvShortcutDecorator(QFrame* parent);
53 
57  ~ecvShortcutDecorator() override = default;
58 
65  void addShortcut(ecvModalShortcut* shortcut);
66 
72  bool isEnabled() const;
73 
74 public Q_SLOTS:
82  virtual void setEnabled(bool enable, bool refocusWhenEnabling = false);
83 
84 protected Q_SLOTS:
89  virtual void onShortcutEnabled();
90 
95  virtual void onShortcutDisabled();
96 
97 protected:
101  QFrame* decoratedFrame() const;
102 
106  bool eventFilter(QObject* obj, QEvent* event) override;
107 
114  void markFrame(bool active, const QColor& frameColor);
115 
118  QList<QPointer<ecvModalShortcut>> m_shortcuts;
119 
122  bool m_pressed;
123 
125  bool m_silent;
126 
131 };
132 
133 #endif // ecvShortcutDecorator_h
MouseEvent event
#define CV_DB_LIB_API
Definition: CV_db.h:15
Manage an action and/or widget's responsivity to a shortcut.
Decorate a widget by highlighting its frame when keyboard shortcuts are active.
~ecvShortcutDecorator() override=default
bool eventFilter(QObject *obj, QEvent *event) override
virtual void setEnabled(bool enable, bool refocusWhenEnabling=false)
ecvShortcutDecorator(QFrame *parent)
bool m_silent
Prevent recursive signaling inside onShortcutEnabled/onShortcutDisabled.
bool isEnabled() const
QList< QPointer< ecvModalShortcut > > m_shortcuts
void markFrame(bool active, const QColor &frameColor)
QFrame * decoratedFrame() const
virtual void onShortcutEnabled()
void addShortcut(ecvModalShortcut *shortcut)
virtual void onShortcutDisabled()