mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-10-18 06:28:44 -05:00
Improve "Get user input" option of variable action
Now also supports ... * file selection * folder selection * scene selection * source selection
This commit is contained in:
@@ -23,6 +23,19 @@ NonModalMessageDialog::NonModalMessageDialog(const QString &message,
|
||||
{
|
||||
}
|
||||
|
||||
NonModalMessageDialog::NonModalMessageDialog(const QString &message,
|
||||
ValueInputType inputType,
|
||||
const std::string &defaultValue,
|
||||
const QStringList &options)
|
||||
: NonModalMessageDialog(message, Type::INPUT)
|
||||
{
|
||||
_valueInput =
|
||||
new ValueInputWidget(inputType, defaultValue, options, this);
|
||||
layout()->replaceWidget(_inputEdit, _valueInput);
|
||||
delete _inputEdit;
|
||||
_inputEdit = nullptr;
|
||||
}
|
||||
|
||||
NonModalMessageDialog::~NonModalMessageDialog()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex);
|
||||
@@ -101,16 +114,21 @@ std::optional<std::string> NonModalMessageDialog::GetInput()
|
||||
{
|
||||
show();
|
||||
|
||||
// Trigger resize
|
||||
_inputEdit->setPlainText(_inputEdit->toPlainText());
|
||||
if (_inputEdit) {
|
||||
// Trigger resize
|
||||
_inputEdit->setPlainText(_inputEdit->toPlainText());
|
||||
}
|
||||
|
||||
exec();
|
||||
deleteLater();
|
||||
|
||||
if (_answer == QMessageBox::Yes) {
|
||||
return _input.toStdString();
|
||||
if (_answer != QMessageBox::Yes) {
|
||||
return {};
|
||||
}
|
||||
return {};
|
||||
if (_valueInput) {
|
||||
return _valueInput->Value();
|
||||
}
|
||||
return _input.toStdString();
|
||||
}
|
||||
|
||||
void NonModalMessageDialog::SetInput(const QString &input)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
#include "resizing-text-edit.hpp"
|
||||
#include "value-input.hpp"
|
||||
|
||||
#include <QDialog>
|
||||
#include <QMessageBox>
|
||||
@@ -19,6 +20,9 @@ public:
|
||||
bool focusAdvssWindow = false);
|
||||
NonModalMessageDialog(const QString &message, bool question,
|
||||
bool focusAdvssWindow = false);
|
||||
NonModalMessageDialog(const QString &message, ValueInputType inputType,
|
||||
const std::string &defaultValue,
|
||||
const QStringList &options);
|
||||
~NonModalMessageDialog();
|
||||
QMessageBox::StandardButton ShowMessage();
|
||||
std::optional<std::string> GetInput();
|
||||
@@ -34,6 +38,7 @@ private:
|
||||
const Type _type;
|
||||
QString _input = "";
|
||||
ResizingPlainTextEdit *_inputEdit = nullptr;
|
||||
ValueInputWidget *_valueInput = nullptr;
|
||||
QMessageBox::StandardButton _answer;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user