diff --git a/qrenderdoc/Windows/PythonShell.cpp b/qrenderdoc/Windows/PythonShell.cpp index 86d32d36d..847ce9719 100644 --- a/qrenderdoc/Windows/PythonShell.cpp +++ b/qrenderdoc/Windows/PythonShell.cpp @@ -76,6 +76,8 @@ EditorWrapper::EditorWrapper(PythonShell *parent) : QFrame(parent), m_PyShell(pa layout()->setSpacing(0); layout()->setMargin(0); layout()->setContentsMargins(0, 0, 0, 0); + + m_Title = tr("Untitled Script"); } EditorWrapper::~EditorWrapper() @@ -86,6 +88,16 @@ EditorWrapper::~EditorWrapper() void EditorWrapper::setFilename(QString filename) { m_Filename = filename; + if(!m_Filename.isEmpty()) + m_Title.clear(); + updateTitle(); +} + +void EditorWrapper::setTitle(QString title) +{ + if(!m_Filename.isEmpty()) + return; + m_Title = title; updateTitle(); } @@ -107,9 +119,9 @@ void EditorWrapper::updateTitle() if(m_Filename.isEmpty()) { if(isModified()) - setWindowTitle(lit("Untitled Script *")); + setWindowTitle(m_Title + lit(" *")); else - setWindowTitle(lit("Untitled Script")); + setWindowTitle(m_Title); } else { @@ -1583,19 +1595,21 @@ void PythonShell::on_projectExplorer_itemActivated(RDTreeWidgetItem *item, int c } else if(item->parent() == m_Examples) { - QString filename = tr("Example: ") + item->text(0); + QString title = tr("Example: ") + item->text(0); QString text = item->data(0, Qt::UserRole).toString(); for(EditorWrapper *edit : m_Editors) { - if(edit->filename() == filename) + if(edit->filename() == title || edit->title() == title) { ToolWindowManager::raiseToolWindow(edit); return; } } - CreateNewScriptEditor(filename, text); + CreateNewScriptEditor("", text); + + m_Editors.back()->setTitle(title); } else { diff --git a/qrenderdoc/Windows/PythonShell.h b/qrenderdoc/Windows/PythonShell.h index 3de4d5723..47b18467c 100644 --- a/qrenderdoc/Windows/PythonShell.h +++ b/qrenderdoc/Windows/PythonShell.h @@ -59,6 +59,7 @@ class EditorWrapper : public QFrame RDLabel *m_Warning; QString m_Filename; + QString m_Title; bool m_Modified = false; bool m_UIExt = false; @@ -74,6 +75,9 @@ public: QString filename() { return m_Filename; } void setFilename(QString filename); + QString title() { return m_Title; } + void setTitle(QString title); + void setWarning(QString text); bool isModified() { return m_Modified; }