18 #include <QKeySequence>
25 m_allowRefocus(false) {
27 CVLog::Error(
"[ecvShortcutDecorator] Cannot decorate null widget!");
32 parent->setLineWidth(2);
33 parent->setFrameStyle(QFrame::NoFrame | QFrame::Plain);
34 this->
markFrame(
false, QColor(0, 0, 0, 0));
37 parent->installEventFilter(
this);
44 "[ecvShortcutDecorator] Attempted to add null shortcut!");
59 CVLog::Print(QString(
"[ecvShortcutDecorator] Added shortcut: %1")
73 return shortcut->isEnabled();
115 shortcut->setEnabled(
false);
121 this->
markFrame(
false, QColor(0, 0, 0, 0));
139 return qobject_cast<QFrame*>(this->parent());
144 if (obj == this->parent()) {
147 return Superclass::eventFilter(obj,
event);
150 switch (
event->type()) {
156 case QEvent::Leave: {
160 : QColor(0, 0, 0, 0));
164 case QEvent::MouseButtonPress:
168 case QEvent::MouseButtonRelease:
193 return Superclass::eventFilter(obj,
event);
205 frame->setFrameShape(QFrame::Box);
206 frame->setLineWidth(2);
209 QString objectName =
frame->objectName();
210 if (objectName.isEmpty()) {
212 objectName = QString(
"ecvDecoratedFrame_%1")
213 .arg(
reinterpret_cast<quintptr
>(
frame));
214 frame->setObjectName(objectName);
217 frame->setStyleSheet(
218 QString(
"QFrame#%1 { border: 2px solid rgba(%2, %3, %4, %5); }")
220 .arg(frameColor.red())
221 .arg(frameColor.green())
222 .arg(frameColor.blue())
223 .arg(frameColor.alpha()));
static bool Warning(const char *format,...)
Prints out a formatted warning message in console.
static bool Print(const char *format,...)
Prints out a formatted message in console.
static bool Error(const char *format,...)
Display an error dialog with formatted message.
void reorder(ecvModalShortcut *target)
static ecvKeySequences & instance()
Manage an action and/or widget's responsivity to a shortcut.
QKeySequence keySequence() const
bool eventFilter(QObject *obj, QEvent *event) override
ecvShortcutDecorator(QFrame *parent)
bool m_silent
Prevent recursive signaling inside onShortcutEnabled/onShortcutDisabled.
QList< QPointer< ecvModalShortcut > > m_shortcuts
QFrame * decoratedFrame() const
virtual void setEnabled(bool enable, bool refocusWhenEnabling=false)
virtual void onShortcutDisabled()
void markFrame(bool active, const QColor &frameColor)
void addShortcut(ecvModalShortcut *shortcut)
virtual void onShortcutEnabled()