From e4834250b9815b7931270cf91b88aa76651d7078 Mon Sep 17 00:00:00 2001
From: Brad Parker <cbparker@gmail.com>
Date: Sat, 18 Aug 2018 12:39:17 -0400
Subject: [PATCH] Qt: set shader dialog title to current preset/shader name

---
 gfx/video_shader_parse.c             |  2 ++
 gfx/video_shader_parse.h             |  1 +
 ui/drivers/qt/shaderparamsdialog.cpp | 16 ++++++++++++++++
 3 files changed, 19 insertions(+)

diff --git a/gfx/video_shader_parse.c b/gfx/video_shader_parse.c
index a70d539c1f..33e0c1674c 100644
--- a/gfx/video_shader_parse.c
+++ b/gfx/video_shader_parse.c
@@ -748,6 +748,8 @@ bool video_shader_read_conf_cgp(config_file_t *conf,
    shader->passes = MIN(shaders, GFX_MAX_SHADERS);
    attr.i         = 0;
 
+   strlcpy(shader->path, conf->path, sizeof(shader->path));
+
    if (settings->bools.video_shader_watch_files)
    {
       if (file_change_data)
diff --git a/gfx/video_shader_parse.h b/gfx/video_shader_parse.h
index 744c7c9ab2..15d228a44f 100644
--- a/gfx/video_shader_parse.h
+++ b/gfx/video_shader_parse.h
@@ -147,6 +147,7 @@ struct video_shader
    char prefix[64];
    char script_class[512];
    char script_path[PATH_MAX_LENGTH];
+   char path[PATH_MAX_LENGTH];
    char *script; /* Dynamically allocated. Must be free'd. Only used by XML. */
 
    bool modern; /* Only used for XML shaders. */
diff --git a/ui/drivers/qt/shaderparamsdialog.cpp b/ui/drivers/qt/shaderparamsdialog.cpp
index 98e532c1bd..6ece4fb62d 100644
--- a/ui/drivers/qt/shaderparamsdialog.cpp
+++ b/ui/drivers/qt/shaderparamsdialog.cpp
@@ -14,6 +14,7 @@
 #include "../ui_qt.h"
 
 extern "C" {
+#include <string/stdstring.h>
 #include "../../../command.h"
 #ifdef HAVE_MENU
 #include "../../../menu/menu_shader.h"
@@ -284,6 +285,7 @@ void ShaderParamsDialog::reload()
 {
    struct video_shader *menu_shader = NULL;
    struct video_shader *video_shader = NULL;
+   const char *shader_path = NULL;
    int i;
    unsigned j;
 
@@ -295,10 +297,24 @@ void ShaderParamsDialog::reload()
     */
 
    if ((video_shader && video_shader->passes == 0) || !video_shader)
+   {
+      setWindowTitle(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SHADER_OPTIONS));
       goto end;
+   }
 
    clearLayout(m_layout);
 
+   /* Only check video_shader for the path, menu_shader seems stale... e.g. if you remove all the shader passes,
+    * it still has the old path in it, but video_shader does not
+    */
+   if (!string_is_empty(video_shader->path))
+   {
+      shader_path = video_shader->path;
+      setWindowTitle(QFileInfo(shader_path).completeBaseName());
+   }
+   else
+      setWindowTitle(msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SHADER_OPTIONS));
+
    /* NOTE: We assume that parameters are always grouped in order by the pass number, e.g., all parameters for pass 0 come first, then params for pass 1, etc. */
    for (i = 0; i < static_cast<int>(video_shader->passes); i++)
    {