mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-07-19 17:49:14 +00:00
Auto suggest scene and source names.
NameDialog can have placeholder text. Localize scene number. Pre-select scene and source text.
This commit is contained in:
parent
978de126b3
commit
6dc84ad8fe
|
@ -42,6 +42,9 @@ Basic.DisplayCapture="Display Capture"
|
|||
Basic.Main.AddSceneDlg.Title="Add Scene"
|
||||
Basic.Main.AddSceneDlg.Text="Please enter the name of the scene"
|
||||
|
||||
# add scene suggested name
|
||||
Basic.Main.DefaultSceneName.Text="Scene %1"
|
||||
|
||||
# add source dialog
|
||||
Basic.SourceSelect.CreateNew="Create new"
|
||||
Basic.SourceSelect.AddExisting="Add Existing"
|
||||
|
|
|
@ -958,10 +958,14 @@ void OBSBasic::on_scenes_customContextMenuRequested(const QPoint &pos)
|
|||
void OBSBasic::on_actionAddScene_triggered()
|
||||
{
|
||||
string name;
|
||||
QString format{QTStr("Basic.Main.DefaultSceneName.Text")};
|
||||
QString placeHolderText = format.arg(ui->scenes->count() + 1);
|
||||
|
||||
bool accepted = NameDialog::AskForName(this,
|
||||
QTStr("MainWindow.AddSceneDlg.Title"),
|
||||
QTStr("MainWindow.AddSceneDlg.Text"),
|
||||
name);
|
||||
name,
|
||||
placeHolderText);
|
||||
|
||||
if (accepted) {
|
||||
if (name.empty()) {
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include "window-basic-main.hpp"
|
||||
#include "window-basic-source-select.hpp"
|
||||
#include "qt-wrappers.hpp"
|
||||
#include "obs-app.hpp"
|
||||
|
||||
bool OBSBasicSourceSelect::EnumSources(void *data, obs_source_t source)
|
||||
{
|
||||
|
@ -143,5 +144,13 @@ OBSBasicSourceSelect::OBSBasicSourceSelect(OBSBasic *parent, const char *type_)
|
|||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
const char *placeHolderText = obs_source_getdisplayname(
|
||||
OBS_SOURCE_TYPE_INPUT,
|
||||
type_, App()->GetLocale());
|
||||
|
||||
ui->sourceName->setText(QT_UTF8(placeHolderText));
|
||||
ui->sourceName->setFocus(); //Fixes deselect of text.
|
||||
ui->sourceName->selectAll();
|
||||
|
||||
obs_enum_sources(EnumSources, this);
|
||||
}
|
||||
|
|
|
@ -28,11 +28,13 @@ NameDialog::NameDialog(QWidget *parent)
|
|||
}
|
||||
|
||||
bool NameDialog::AskForName(QWidget *parent, const QString &title,
|
||||
const QString &text, string &str)
|
||||
const QString &text, string &str, const QString &placeHolder)
|
||||
{
|
||||
NameDialog dialog(parent);
|
||||
dialog.setWindowTitle(title);
|
||||
dialog.ui->label->setText(text);
|
||||
dialog.ui->userText->setText(placeHolder);
|
||||
dialog.ui->userText->selectAll();
|
||||
|
||||
bool accepted = (dialog.exec() == DialogCode::Accepted);
|
||||
if (accepted)
|
||||
|
|
|
@ -33,5 +33,6 @@ public:
|
|||
NameDialog(QWidget *parent);
|
||||
|
||||
static bool AskForName(QWidget *parent, const QString &title,
|
||||
const QString &text, std::string &str);
|
||||
const QString &text, std::string &str,
|
||||
const QString &placeHolder = QString(""));
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue