src/platform/qt/KeyEditor.h (view raw)
1/* Copyright (c) 2013-2014 Jeffrey Pfau
2 *
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6#ifndef QGBA_KEY_EDITOR
7#define QGBA_KEY_EDITOR
8
9#include "InputController.h"
10#include <QLineEdit>
11
12namespace QGBA {
13
14class KeyEditor : public QLineEdit {
15Q_OBJECT
16
17public:
18 KeyEditor(QWidget* parent = nullptr);
19
20 void setValue(int key);
21 int value() const { return m_key; }
22
23 void setValueKey(int key);
24 void setValueButton(int button);
25 void setValueAxis(int axis, int32_t value);
26 InputController::Direction direction() const { return m_direction; }
27
28 virtual QSize sizeHint() const override;
29
30signals:
31 void valueChanged(int key);
32 void axisChanged(int key, int direction);
33
34protected:
35 virtual void keyPressEvent(QKeyEvent* event) override;
36
37private:
38 int m_key;
39 bool m_button;
40 InputController::Direction m_direction;
41};
42
43}
44
45#endif