From c39aef03fe6c6b33469bdba1f4134d905f8d8256 Mon Sep 17 00:00:00 2001 From: Matt Gajownik Date: Thu, 30 Jul 2020 23:07:36 +1000 Subject: [PATCH] frontend-tools: Add context menu to Scripts list --- .../frontend-tools/data/locale/en-US.ini | 1 + .../frontend-tools/forms/scripts.ui | 3 +++ .../frontend-tools/scripts.cpp | 25 +++++++++++++++++++ .../frontend-tools/scripts.hpp | 1 + 4 files changed, 30 insertions(+) diff --git a/UI/frontend-plugins/frontend-tools/data/locale/en-US.ini b/UI/frontend-plugins/frontend-tools/data/locale/en-US.ini index 298b53bfe..2df4ff67e 100644 --- a/UI/frontend-plugins/frontend-tools/data/locale/en-US.ini +++ b/UI/frontend-plugins/frontend-tools/data/locale/en-US.ini @@ -32,6 +32,7 @@ AddScripts="Add Scripts" RemoveScripts="Remove Scripts" ReloadScripts="Reload Scripts" LoadedScripts="Loaded Scripts" +Reload="Reload" PythonSettings="Python Settings" PythonSettings.PythonInstallPath32bit="Python Install Path (32bit)" PythonSettings.PythonInstallPath64bit="Python Install Path (64bit)" diff --git a/UI/frontend-plugins/frontend-tools/forms/scripts.ui b/UI/frontend-plugins/frontend-tools/forms/scripts.ui index 7ff1f08cf..e4c299a6e 100644 --- a/UI/frontend-plugins/frontend-tools/forms/scripts.ui +++ b/UI/frontend-plugins/frontend-tools/forms/scripts.ui @@ -41,6 +41,9 @@ + + Qt::CustomContextMenu + true diff --git a/UI/frontend-plugins/frontend-tools/scripts.cpp b/UI/frontend-plugins/frontend-tools/scripts.cpp index 81507a3ed..6bf920c82 100644 --- a/UI/frontend-plugins/frontend-tools/scripts.cpp +++ b/UI/frontend-plugins/frontend-tools/scripts.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -389,6 +390,30 @@ void ScriptsTool::on_reloadScripts_clicked() on_scripts_currentRowChanged(ui->scripts->currentRow()); } +void ScriptsTool::on_scripts_customContextMenuRequested(const QPoint &pos) +{ + + QListWidgetItem *item = ui->scripts->itemAt(pos); + + QMenu popup(this); + + obs_frontend_push_ui_translation(obs_module_get_string); + + popup.addAction(tr("Add"), this, SLOT(on_addScripts_clicked())); + + if (item) { + popup.addSeparator(); + popup.addAction(obs_module_text("Reload"), this, + SLOT(on_reloadScripts_clicked())); + popup.addSeparator(); + popup.addAction(tr("Remove"), this, + SLOT(on_removeScripts_clicked())); + } + obs_frontend_pop_ui_translation(); + + popup.exec(QCursor::pos()); +} + void ScriptsTool::on_scriptLog_clicked() { scriptLogWindow->show(); diff --git a/UI/frontend-plugins/frontend-tools/scripts.hpp b/UI/frontend-plugins/frontend-tools/scripts.hpp index c86f46f81..8eedf7afc 100644 --- a/UI/frontend-plugins/frontend-tools/scripts.hpp +++ b/UI/frontend-plugins/frontend-tools/scripts.hpp @@ -54,4 +54,5 @@ public slots: private slots: void on_description_linkActivated(const QString &link); + void on_scripts_customContextMenuRequested(const QPoint &pos); };