dragonpilot - 基於 openpilot 的開源駕駛輔助系統
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
2.0 KiB

#pragma once
#include <QDialog>
#include <QLabel>
#include <QLineEdit>
#include <QString>
#include <QVBoxLayout>
#include <QWidget>
#include "selfdrive/ui/qt/widgets/keyboard.h"
class QDialogBase : public QDialog {
Q_OBJECT
protected:
QDialogBase(QWidget *parent);
bool eventFilter(QObject *o, QEvent *e) override;
public slots:
int exec() override;
};
class InputDialog : public QDialogBase {
Q_OBJECT
public:
explicit InputDialog(const QString &title, QWidget *parent, const QString &subtitle = "", bool secret = false);
static QString getText(const QString &title, QWidget *parent, const QString &substitle = "",
bool secret = false, int minLength = -1, const QString &defaultText = "");
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;
QLabel *sublabel;
QVBoxLayout *main_layout;
QPushButton *eye_btn;
private slots:
void handleEnter();
signals:
void cancel();
void emitText(const QString &text);
};
class ConfirmationDialog : public QDialogBase {
Q_OBJECT
public:
explicit ConfirmationDialog(const QString &prompt_text, const QString &confirm_text,
const QString &cancel_text, QWidget* parent);
static bool alert(const QString &prompt_text, QWidget *parent);
static bool confirm(const QString &prompt_text, QWidget *parent);
};
// larger ConfirmationDialog for rich text
class RichTextDialog : public QDialogBase {
Q_OBJECT
public:
explicit RichTextDialog(const QString &prompt_text, const QString &btn_text, QWidget* parent);
static bool alert(const QString &prompt_text, QWidget *parent);
};
UI: Internationalization support (#21212) * rough multiple language demo * more wrappings * stash * add some bad translations * updates * map from french to spanish still has same problem of needing to call setText on everything * add files * restart UI * use return code * relative path * more translations * don't loop restart * Toggle and prime translations * try on device * try QComboBox with readable style * stash * not yet scrollable * stash * dynamic translations (doesn't work for dynamic widget strings yet) * clean up multiple option selector * store languages in json * try transparent * Try transparent popup * see how this looks * tweaks * clean up * update names * Add Chinese (Simplified) translations * Do missing French translations * unit tests caught that :) * fix test * fix other test (on PC) * add entries to dialog to test * add cancel button, clean up a bit * just chinese * some clean up * use quotes * clean up * Just quit, set timeout to 0 * half a second * use exitcode * don't print if it's expected * this comment is outdated * update translations * Update translations * re-order input classes * Update line numbers * use enabled property for button style * Get rid of ListWidget * Update line numbers * Log failed to load language * Log failed to load language * Move to utils and fix english logging extra line * Update translations * spacing * looks a bit better * try this instead of exitcode fixes fix * only one function * comment * Update line numbers * fixup some japanese translations * clean up multi option dialog * Update line numbers
3 years ago
class MultiOptionDialog : public QDialogBase {
Q_OBJECT
public:
explicit MultiOptionDialog(const QString &prompt_text, const QStringList l, QWidget *parent);
static QString getSelection(const QString &prompt_text, const QStringList l, QWidget *parent);
QString selection;
};