From 6597206d934ac0b113e219ee9398d4645bff6961 Mon Sep 17 00:00:00 2001 From: Socapex Date: Tue, 12 Aug 2014 15:09:19 -0400 Subject: [PATCH] Alert user when using existing source name. --- obs/data/locale/en-US.ini | 3 ++- obs/window-basic-main.cpp | 21 ++++++++++++++++----- obs/window-basic-source-select.cpp | 4 ++-- 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/obs/data/locale/en-US.ini b/obs/data/locale/en-US.ini index 8f2b3175e..b6d77b8a7 100644 --- a/obs/data/locale/en-US.ini +++ b/obs/data/locale/en-US.ini @@ -30,7 +30,8 @@ DroppedFrames="Dropped Frames %1 (%2%)" NameExists.Title="Name already exists" NameExists.Text="The name is already in use." -NoNameEntered="Please enter a valid name" +NoNameEntered.Title="Please enter a valid name" +NoNameEntered.Text="You cannot use empty names." # confirm delete dialog box ConfirmRemove.Title="Confirm Remove" diff --git a/obs/window-basic-main.cpp b/obs/window-basic-main.cpp index 865686d7c..1d47dc6ea 100644 --- a/obs/window-basic-main.cpp +++ b/obs/window-basic-main.cpp @@ -1480,8 +1480,8 @@ void OBSBasic::on_actionAddScene_triggered() if (accepted) { if (name.empty()) { QMessageBox::information(this, - QTStr("NoNameEntered"), - QTStr("NoNameEntered")); + QTStr("NoNameEntered.Title"), + QTStr("NoNameEntered.Text")); on_actionAddScene_triggered(); return; } @@ -1818,7 +1818,7 @@ void OBSBasic::logUploadFinished() logDialog.exec(); } -static void RenameListItem(QListWidget *listWidget, obs_source_t source, +static void RenameListItem(OBSBasic *parent, QListWidget *listWidget, obs_source_t source, const string &name) { const char *prevName = obs_source_get_name(source); @@ -1827,6 +1827,17 @@ static void RenameListItem(QListWidget *listWidget, obs_source_t source, if (foundSource || name.compare(prevName) == 0 || name.empty()) { listItem->setText(QT_UTF8(prevName)); + + if (foundSource || name.compare(prevName) == 0) { + QMessageBox::information(parent, + QTStr("NameExists.Title"), + QTStr("NameExists.Text")); + } else if (name.empty()) { + QMessageBox::information(parent, + QTStr("NoNameEntered.Title"), + QTStr("NoNameEntered.Text")); + } + obs_source_release(foundSource); } else { listItem->setText(QT_UTF8(name.c_str())); @@ -1845,7 +1856,7 @@ void OBSBasic::SceneNameEdited(QWidget *editor, return; obs_source_t source = obs_scene_get_source(scene); - RenameListItem(ui->scenes, source, text); + RenameListItem(this, ui->scenes, source, text); UNUSED_PARAMETER(endHint); } @@ -1861,7 +1872,7 @@ void OBSBasic::SceneItemNameEdited(QWidget *editor, return; obs_source_t source = obs_sceneitem_get_source(item); - RenameListItem(ui->sources, source, text); + RenameListItem(this, ui->sources, source, text); UNUSED_PARAMETER(endHint); } diff --git a/obs/window-basic-source-select.cpp b/obs/window-basic-source-select.cpp index 4ae207fbf..fd32a13c5 100644 --- a/obs/window-basic-source-select.cpp +++ b/obs/window-basic-source-select.cpp @@ -140,8 +140,8 @@ void OBSBasicSourceSelect::on_buttonBox_accepted() } else { if (ui->sourceName->text().isEmpty()) { QMessageBox::information(this, - QTStr("NoNameEntered"), - QTStr("NoNameEntered")); + QTStr("NoNameEntered.Title"), + QTStr("NoNameEntered.Text")); return; }