aboutsummaryrefslogtreecommitdiff
path: root/include/widgets/CommandInput.hpp
blob: 3ce9500c95c86e6bc0f4bd4f627b22d124bc89c9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#pragma once

#include <QBoxLayout>
#include <QLineEdit>
#include <QWidget>
#include <QtCore>

class CommandInput : public QWidget {
  Q_OBJECT

public:
  CommandInput(QString defaultInput = "", QWidget *parentNode = nullptr);
  void setInputFocus(bool focussed);
  bool isInputFocussed();
  QString getInputCommand();
  void setInputText(QString text);

signals:
  void submitted(QString command);
  void cancelled();

protected:
  void keyPressEvent(QKeyEvent *event) override;
  void emitSubmit();

private:
  QBoxLayout *layout;
  QLineEdit *input;
};