Browse Source

frontend-tools: Add "Open file location" menu item for scripts

Matt Gajownik 5 years ago
parent
commit
a4bef68b15

+ 1 - 0
UI/frontend-plugins/frontend-tools/data/locale/en-US.ini

@@ -33,6 +33,7 @@ RemoveScripts="Remove Scripts"
 ReloadScripts="Reload Scripts"
 LoadedScripts="Loaded Scripts"
 Reload="Reload"
+OpenFileLocation="Open file location"
 PythonSettings="Python Settings"
 PythonSettings.PythonInstallPath32bit="Python Install Path (32bit)"
 PythonSettings.PythonInstallPath64bit="Python Install Path (64bit)"

+ 13 - 0
UI/frontend-plugins/frontend-tools/scripts.cpp

@@ -390,6 +390,17 @@ void ScriptsTool::on_reloadScripts_clicked()
 	on_scripts_currentRowChanged(ui->scripts->currentRow());
 }
 
+void ScriptsTool::OpenScriptParentDirectory()
+{
+	QList<QListWidgetItem *> items = ui->scripts->selectedItems();
+	for (QListWidgetItem *item : items) {
+		QDir dir(item->data(Qt::UserRole).toString());
+		dir.cdUp();
+		QDesktopServices::openUrl(
+			QUrl::fromLocalFile(dir.absolutePath()));
+	}
+}
+
 void ScriptsTool::on_scripts_customContextMenuRequested(const QPoint &pos)
 {
 
@@ -405,6 +416,8 @@ void ScriptsTool::on_scripts_customContextMenuRequested(const QPoint &pos)
 		popup.addSeparator();
 		popup.addAction(obs_module_text("Reload"), this,
 				SLOT(on_reloadScripts_clicked()));
+		popup.addAction(obs_module_text("OpenFileLocation"), this,
+				SLOT(OpenScriptParentDirectory()));
 		popup.addSeparator();
 		popup.addAction(tr("Remove"), this,
 				SLOT(on_removeScripts_clicked()));

+ 2 - 0
UI/frontend-plugins/frontend-tools/scripts.hpp

@@ -48,6 +48,8 @@ public slots:
 	void on_scriptLog_clicked();
 	void on_defaults_clicked();
 
+	void OpenScriptParentDirectory();
+
 	void on_scripts_currentRowChanged(int row);
 
 	void on_pythonPathBrowse_clicked();