summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Zach Hilman2018-11-17 14:44:16 -0500
committerGravatar Zach Hilman2018-11-18 10:53:47 -0500
commit56cf5b7b17cd87f4a23bd45ae661762ce1fda5d1 (patch)
treeb5a91d110ae92844596e1bf70206984db330f204
parentsoftware_keyboard: Push all data over all channels on dialog completion (diff)
downloadyuzu-56cf5b7b17cd87f4a23bd45ae661762ce1fda5d1.tar.gz
yuzu-56cf5b7b17cd87f4a23bd45ae661762ce1fda5d1.tar.xz
yuzu-56cf5b7b17cd87f4a23bd45ae661762ce1fda5d1.zip
software_keyboard: Add max and current length display to dialog
-rw-r--r--src/yuzu/applets/software_keyboard.cpp11
-rw-r--r--src/yuzu/applets/software_keyboard.h1
2 files changed, 11 insertions, 1 deletions
diff --git a/src/yuzu/applets/software_keyboard.cpp b/src/yuzu/applets/software_keyboard.cpp
index 83b9c320b..efefb1f99 100644
--- a/src/yuzu/applets/software_keyboard.cpp
+++ b/src/yuzu/applets/software_keyboard.cpp
@@ -47,7 +47,7 @@ QtSoftwareKeyboardDialog::QtSoftwareKeyboardDialog(
47 layout = new QVBoxLayout; 47 layout = new QVBoxLayout;
48 48
49 header_label = new QLabel(QString::fromStdU16String(parameters.header_text)); 49 header_label = new QLabel(QString::fromStdU16String(parameters.header_text));
50 header_label->setFont({header_label->font().family(), 12, QFont::Bold}); 50 header_label->setFont({header_label->font().family(), 11, QFont::Bold});
51 if (header_label->text().isEmpty()) 51 if (header_label->text().isEmpty())
52 header_label->setText(tr("Enter text:")); 52 header_label->setText(tr("Enter text:"));
53 53
@@ -59,6 +59,10 @@ QtSoftwareKeyboardDialog::QtSoftwareKeyboardDialog(
59 guide_label = new QLabel(QString::fromStdU16String(parameters.guide_text)); 59 guide_label = new QLabel(QString::fromStdU16String(parameters.guide_text));
60 guide_label->setHidden(parameters.guide_text.empty()); 60 guide_label->setHidden(parameters.guide_text.empty());
61 61
62 length_label = new QLabel(QStringLiteral("0/%1").arg(parameters.max_length));
63 length_label->setAlignment(Qt::AlignRight);
64 length_label->setFont({length_label->font().family(), 8});
65
62 line_edit = new QLineEdit; 66 line_edit = new QLineEdit;
63 line_edit->setValidator(new QtSoftwareKeyboardValidator(parameters)); 67 line_edit->setValidator(new QtSoftwareKeyboardValidator(parameters));
64 line_edit->setMaxLength(static_cast<int>(parameters.max_length)); 68 line_edit->setMaxLength(static_cast<int>(parameters.max_length));
@@ -67,6 +71,10 @@ QtSoftwareKeyboardDialog::QtSoftwareKeyboardDialog(
67 parameters.cursor_at_beginning ? 0 : static_cast<int>(parameters.initial_text.size())); 71 parameters.cursor_at_beginning ? 0 : static_cast<int>(parameters.initial_text.size()));
68 line_edit->setEchoMode(parameters.password ? QLineEdit::Password : QLineEdit::Normal); 72 line_edit->setEchoMode(parameters.password ? QLineEdit::Password : QLineEdit::Normal);
69 73
74 connect(line_edit, &QLineEdit::textChanged, this, [this](const QString& text) {
75 length_label->setText(QStringLiteral("%1/%2").arg(text.size()).arg(parameters.max_length));
76 });
77
70 buttons = new QDialogButtonBox; 78 buttons = new QDialogButtonBox;
71 buttons->addButton(tr("Cancel"), QDialogButtonBox::RejectRole); 79 buttons->addButton(tr("Cancel"), QDialogButtonBox::RejectRole);
72 buttons->addButton(parameters.submit_text.empty() 80 buttons->addButton(parameters.submit_text.empty()
@@ -79,6 +87,7 @@ QtSoftwareKeyboardDialog::QtSoftwareKeyboardDialog(
79 layout->addWidget(header_label); 87 layout->addWidget(header_label);
80 layout->addWidget(sub_label); 88 layout->addWidget(sub_label);
81 layout->addWidget(guide_label); 89 layout->addWidget(guide_label);
90 layout->addWidget(length_label);
82 layout->addWidget(line_edit); 91 layout->addWidget(line_edit);
83 layout->addWidget(buttons); 92 layout->addWidget(buttons);
84 setLayout(layout); 93 setLayout(layout);
diff --git a/src/yuzu/applets/software_keyboard.h b/src/yuzu/applets/software_keyboard.h
index 8d56f5db2..73f56714f 100644
--- a/src/yuzu/applets/software_keyboard.h
+++ b/src/yuzu/applets/software_keyboard.h
@@ -47,6 +47,7 @@ private:
47 QLabel* header_label; 47 QLabel* header_label;
48 QLabel* sub_label; 48 QLabel* sub_label;
49 QLabel* guide_label; 49 QLabel* guide_label;
50 QLabel* length_label;
50 QLineEdit* line_edit; 51 QLineEdit* line_edit;
51 QVBoxLayout* layout; 52 QVBoxLayout* layout;
52 53