Files
StarPilot/selfdrive/ui/qt/widgets/input.hpp
T
iejMac fbe27337ca UI: close dialogs on settings close (#20541)
* this works

* fix

* fix

* fix

* blacklist

* style

* tabs

* tabs

* temporary

* hideEvent

* fix

* changes

* dont need this

* works

* no signal

* Merge branch 'master' of github.com:commaai/openpilot into ui_close_after_timeout

* works

* cleanup

* little more cleanup

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
old-commit-hash: 0fe155b7c30e9db4bd08b61d8e7e325ec58ac24a
2021-04-23 21:24:53 -07:00

57 lines
1.2 KiB
C++

#pragma once
#include <QLabel>
#include <QString>
#include <QWidget>
#include <QDialog>
#include <QLineEdit>
#include <QVBoxLayout>
#include "keyboard.hpp"
class InputDialog : public QDialog {
Q_OBJECT
public:
explicit InputDialog(const QString &prompt_text, QWidget* parent = 0);
static QString getText(const QString &prompt, int minLength = -1);
QString text();
void setMessage(const QString &message, bool clearInputField = true);
void setMinLength(int length);
void show();
private:
int minLength;
QLineEdit *line;
Keyboard *k;
QLabel *label;
QVBoxLayout *layout;
public slots:
int exec() override;
private slots:
void handleInput(const QString &s);
signals:
void cancel();
void emitText(const QString &text);
};
class ConfirmationDialog : public QDialog {
Q_OBJECT
public:
explicit ConfirmationDialog(const QString &prompt_text, const QString &confirm_text = "Ok",
const QString &cancel_text = "Cancel", QWidget* parent = 0);
static bool alert(const QString &prompt_text, QWidget *parent = 0);
static bool confirm(const QString &prompt_text, QWidget *parent = 0);
private:
QLabel *prompt;
QVBoxLayout *layout;
public slots:
int exec() override;
};