Make 'remove' toolbar buttons query for removal

This commit is contained in:
jp9000 2014-06-30 13:45:58 -07:00
parent 476fa6b757
commit 66c3c862e4
2 changed files with 39 additions and 22 deletions

View file

@ -92,7 +92,7 @@ OBSBasic::OBSBasic(QWidget *parent)
removeItemAction = new QAction(QTStr("Remove"), this);
removeItemAction->setShortcut(QKeySequence(Qt::Key_Delete));
connect(removeItemAction, SIGNAL(triggered()),
this, SLOT(RemoveSelectedItem()));
this, SLOT(RemoveSelectedSceneItem()));
addAction(removeItemAction);
}
@ -792,21 +792,36 @@ void OBSBasic::DeactivateAudioSource(OBSSource source)
}
}
void OBSBasic::RemoveSelectedItem()
bool OBSBasic::QueryRemoveSource(obs_source_t source)
{
const char *name = obs_source_getname(source);
QString text = QTStr("ConfirmRemove.Text");
text.replace("$1", QT_UTF8(name));
QMessageBox::StandardButton button;
button = QMessageBox::question(this,
QTStr("ConfirmRemove.Remove"), text);
return button == QMessageBox::Yes;
}
void OBSBasic::RemoveSelectedScene()
{
OBSScene scene = GetCurrentScene();
if (scene) {
obs_source_t source = obs_scene_getsource(scene);
if (QueryRemoveSource(source))
obs_source_remove(source);
}
}
void OBSBasic::RemoveSelectedSceneItem()
{
OBSSceneItem item = GetCurrentSceneItem();
if (item) {
obs_source_t source = obs_sceneitem_getsource(item);
const char *name = obs_source_getname(source);
QString text = QTStr("ConfirmRemove.Text");
text.replace("$1", QT_UTF8(name));
QMessageBox::StandardButton button;
button = QMessageBox::question(this,
QTStr("ConfirmRemove.Remove"), text);
if (button == QMessageBox::Yes)
if (QueryRemoveSource(source))
obs_sceneitem_remove(item);
}
}
@ -1297,14 +1312,11 @@ void OBSBasic::on_actionAddScene_triggered()
void OBSBasic::on_actionRemoveScene_triggered()
{
QListWidgetItem *item = ui->scenes->currentItem();
if (!item)
return;
QVariant userData = item->data(Qt::UserRole);
obs_scene_t scene = userData.value<OBSScene>();
OBSScene scene = GetCurrentScene();
obs_source_t source = obs_scene_getsource(scene);
obs_source_remove(source);
if (source && QueryRemoveSource(source))
obs_source_remove(source);
}
void OBSBasic::on_actionSceneProperties_triggered()
@ -1445,8 +1457,10 @@ void OBSBasic::on_actionAddSource_triggered()
void OBSBasic::on_actionRemoveSource_triggered()
{
OBSSceneItem item = GetCurrentSceneItem();
if (item)
OBSSceneItem item = GetCurrentSceneItem();
obs_source_t source = obs_sceneitem_getsource(item);
if (source && QueryRemoveSource(source))
obs_sceneitem_remove(item);
}

View file

@ -116,6 +116,8 @@ private:
OBSSceneItem GetCurrentSceneItem();
bool QueryRemoveSource(obs_source_t source);
void GetFPSCommon(uint32_t &num, uint32_t &den) const;
void GetFPSInteger(uint32_t &num, uint32_t &den) const;
void GetFPSFraction(uint32_t &num, uint32_t &den) const;
@ -148,7 +150,8 @@ private slots:
void ActivateAudioSource(OBSSource source);
void DeactivateAudioSource(OBSSource source);
void RemoveSelectedItem();
void RemoveSelectedScene();
void RemoveSelectedSceneItem();
private:
/* OBS Callbacks */