|
| 1 | +/* |
| 2 | + * Stellarium |
| 3 | + * Copyright (C) 2021 Georg Zotti |
| 4 | + * |
| 5 | + * This program is free software; you can redistribute it and/or |
| 6 | + * modify it under the terms of the GNU General Public License |
| 7 | + * as published by the Free Software Foundation; either version 2 |
| 8 | + * of the License, or (at your option) any later version. |
| 9 | + * |
| 10 | + * This program is distributed in the hope that it will be useful, |
| 11 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | + * GNU General Public License for more details. |
| 14 | + * |
| 15 | + * You should have received a copy of the GNU General Public License |
| 16 | + * along with this program; if not, write to the Free Software |
| 17 | + * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA. |
| 18 | + */ |
| 19 | + |
| 20 | +#ifndef SPACEPUSHBUTTON_HPP |
| 21 | +#define SPACEPUSHBUTTON_HPP |
| 22 | + |
| 23 | +#include <QPushButton> |
| 24 | + |
| 25 | +//! @class SpacePushButton |
| 26 | +//! A QPushButton which can be triggered by pressing Space when it has focus. |
| 27 | +//! To use this class in the QtCreator UI designer, add a regular QPushButton to the UI, |
| 28 | +//! then right-click on it and change its type to SpacePushButton. |
| 29 | +//! Then it makes sense to put this button into a useful GUI tab order. |
| 30 | +class SpacePushButton : public QPushButton |
| 31 | +{ |
| 32 | + Q_OBJECT |
| 33 | +public: |
| 34 | + SpacePushButton(QWidget* parent=Q_NULLPTR); |
| 35 | + ~SpacePushButton() Q_DECL_OVERRIDE {} |
| 36 | + |
| 37 | +protected: |
| 38 | + //! This triggers the button on pressing the Space bar. |
| 39 | + virtual void keyPressEvent(QKeyEvent *e) Q_DECL_OVERRIDE; |
| 40 | +}; |
| 41 | + |
| 42 | +#endif // SPACEPUSHBUTTON_HPP |
0 commit comments