File indexing completed on 2024-11-24 03:56:28

0001 /*
0002  * SPDX-FileCopyrightText: 2019-2023 Mattia Basaglia <dev@dragon.best>
0003  *
0004  * SPDX-License-Identifier: GPL-3.0-or-later
0005  */
0006 
0007 #pragma once
0008 
0009 #include <QKeyEvent>
0010 
0011 namespace app::widgets {
0012 
0013 class NoCloseOnEnter : public QObject
0014 {
0015 protected:
0016     bool eventFilter(QObject *obj, QEvent *event) override
0017     {
0018         if (event->type() == QEvent::KeyPress)
0019         {
0020             QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
0021             if ( keyEvent->key() == Qt::Key_Return || keyEvent->key() == Qt::Key_Enter )
0022                 return true;
0023         }
0024 
0025         return QObject::eventFilter(obj, event);
0026     }
0027 };
0028 
0029 
0030 } // namespace app::widgets