Add option to set placeholder text when asking for input

This commit is contained in:
WarmUpTill
2023-08-28 20:28:33 +02:00
committed by WarmUpTill
parent 6b6e37da92
commit fdf1a94f97
5 changed files with 97 additions and 19 deletions

View File

@@ -75,7 +75,7 @@ std::optional<std::string> NonModalMessageDialog::GetInput()
show();
// Trigger resize
_inputEdit->setPlainText("");
_inputEdit->setPlainText(_inputEdit->toPlainText());
exec();
this->deleteLater();
@@ -85,6 +85,12 @@ std::optional<std::string> NonModalMessageDialog::GetInput()
return {};
}
void NonModalMessageDialog::SetInput(const QString &input)
{
assert(_type == Type::INPUT);
_inputEdit->setPlainText(input);
}
void NonModalMessageDialog::YesClicked()
{
_answer = QMessageBox::Yes;

View File

@@ -19,7 +19,8 @@ public:
NonModalMessageDialog(const QString &message, bool question);
QMessageBox::StandardButton ShowMessage();
std::optional<std::string> GetInput();
Type GetType() { return _type; }
Type GetType() const { return _type; }
void SetInput(const QString &);
private slots:
void YesClicked();